#REF, #NAME errors in Getpivotdata Formula - excel

While trying to get data from a Pivot table using formula,
=GETPIVOTDATA(A4:F12,$A$4,"Severity",$A$23,"Current Status",$C$20)
This code gives me a "#REF" Error and
=GETPIVOTDATA(Count of Issue Number,PivotTable1,"Severity",$A$23,"Current Status",$C$20)
This one gives a "#NAME" Error. What should I do?

You need to enclose field names in quotes, and the second argument should be one cell within the pivot table:
=GETPIVOTDATA("Count of Issue Number",$A$4,"Severity",$A$23,"Current Status",$C$20)

Related

Formula syntax (Counting unique values with conditionals)

I've got this formula
=COUNTA(UNIQUE(
FILTER($B$2:$B$10,
(($C$2:$C$10<DATEVALUE("1/5/2021"))*
($C$2:$C$10>=DATEVALUE("1/1/2021"))*
($A$2:$A$10=$F2)))))
and I want to modify it so I can use it with my own workbook references, but I keep getting a syntax error and I can't see where this is happening.
This is the formula I'm trying to create
=COUNTA(UNIQUE(
FILTER(MachineData!B:B,
((MachineData!C:C,">="&$Q$15-30)*
(MachineData!$C:$C,"<="&$Q$15+0.999988)*
(MachineData!N:N= $S$108)))))
Note: &$Q$15 has the date I'm referencing and I'm just trying to use the past month as my reference for the date ranges.
As I mentioned in comment try below formula-
=COUNTA(UNIQUE(FILTER(MachineData!B:B,((MachineData!C:C>=$Q$15-30)*(MachineData!$C:$C<=$Q$15+0.999988)*(MachineData!N:N=$S$108)))))

Excel Filter formula with named ranges

I'm looking to use the filter formula on a named range but there hasn't been a resource that has explicitly showed how to reference columns within a named range. I might add that the whole named range includes the headers due to the nature of the original data. It has 13 Columns.
The columns I want with their position is: "Injury Date" (6) and "INCURRED" (8)
=filter(Loss_Run,[Insert Chosen Columns Here])
This is the syntax I am trying to use but I cannot get it to work. I am not sure how to tell it to use the columns I want. Do I use the name of the columns or the number either way is fine to me.
I am trying to filter by a specfic value of a row and that is where the main hiccup is.
I got
=FILTER(Loss_Run,(Loss_Columns="Injury Date")+(Loss_Columns="INCURRED"))
to work.
BUT,
I want to first filter the first column, "ULGTACCT Code" (1) by a value (that is in cell A2 for our purposes). It is not allowing me to filter by the first column with or with out the other columns
What I have found says:
=FILTER(Loss_Run,(ULGTACCT Code=$A$2),"")
should work but I get #Name? error.
To answer about calling a column within a table with name ranges and the FILTER function is things are much smoother if you specify columns as =FILTER(TableName[ColumnName],include"argument") within brackets "[ ]", this means that your table will need to be named to make this easier. That's how you would call a specific column.
To the other point of specifying the columns to FILTER, I have only found that to do this you write it as =FILTER(TableName[#[ComlumnName1]:[ColumnName4]],include"argument") and that should do it but I get an #Value error doing that.
I'm looking for any help as well with this so if this helps to bring you to a answer please share.
I was using
=FILTER(TableName, (TableName[Column]="SearchValue")
And I got all table rows back that were matching the criteria.

GetPivotData #REF Error, data format issue?

I am getting a #Ref error when I try to reference an element from a pivottable.
I am literally doing a "=" and clicking on the pivot table to get the formula and even that is returning a #REF error.
To be a bit more specific, I am using a pivot table to sum up a datafield across some rows and columns. The columns have numbers formatted as string, so when I do the formula I get:
=getpivotdata("my_sum", ptable_ref, col_name, "COL_VAL", row_name, row_val)
COL_VAL is a number like 123, 234 but formatted as a string. Right now when I do the formula for "123" it works, but the same formula for "234" gives me a #REF error. If I leave off the quotes to use the number itself, I still get an error.
I've restarted excel and my computer, but that doesn't help. The data is being pulled from a database query, but col_name is the same format for all of them. I don't see any trailing or leading spaces either. I am scratching my head about what this could be. I'd rather not have to iterate through the rows for the values I need and just use the function to make it easy on myself.
If some of you are looking for an error handling (#ref error might be caused by filters):
=if(isError(formula);defaultValue;formula)
In Excel you can define names/variables for long expressions, e.g
formula=getpivotdata("my_sum", ptable_ref, col_name, "COL_VAL", row_name, row_val)

Complie error: Expected Separator or )

I'm attempting to make a macro to insert a formula into a cell range that references a table on the page, but I'm getting the compile error. Can anyone give me a hand with this? It doesn't seem to like that I'm referencing a Table (or the #Duration part anyways, but this is necessary). I basically just need it to drop this formula string into the required cells.
Code:
Range("A2:A100").Formula = MID(Table4[#Duration],FIND("m",Table4[#Duration],1)-1,7)
Thanks.
the formula needs to be in quotes:
Range("A2:A100").Formula = "=MID(Table4[#Duration],FIND(""m"",Table4[#Duration],1)-1,7)"

How to use wildcard in Cubevalue formula in Excel?

I am trying to get the values with wildcard in Cubevalue formula(below) in excel. I am not finding any solution.
=CUBEVALUE("ThisWorkbookDataModel","[Measures].[Sum of Bookings_Net]","[Dashboard_Data].[Level_1].[Karnataka_India]")
I am trying to get the values where [level 1] ends with [_India], I don't want to create a calculated Column in Data Model as this condition may be used for different columns and different conditions.
I have also tried by giving cell reference(eg-[Cell A1] = "_India) as like below but I am not able to get the results.
CUBEVALUE("ThisWorkbookDataModel","[Measures].[Sum of Bookings_Net]","[Dashboard_Data].[Level_1].["&A$1&"]")
kindly help me to overcome this issue.
First create a =CUBESET function in cell A1.
=CUBESET("ThisWorkbookDataModel","Filter([Dashboard_Data].[Level_1].[Level_1].Members, Right([Dashboard_Data].[Level_1].CurrentMember.Name, 6)=""_India"")")
Basically that is a language called MDX and the expression before "" double quote escaping is:
Filter([Dashboard_Data].[Level_1].[Level_1].Members, Right([Dashboard_Data].[Level_1].CurrentMember.Name, 6)="_India")
Then reference it in your =CUBEVALUE formula:
=CUBEVALUE("ThisWorkbookDataModel","[Measures].[Sum of Bookings_Net]",$A$1)

Resources