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)
Related
In a for-loop after 50+ iterations I get the error With Vlookup in VBA.
And when debugging:
I tried to add the CStr() in the lookup value argument, but that did not help.
Range DB in the sheet:
Is it the two leading zeros that it cannot recognize in the table?
However, I have another case where the strings begins with letters and i still get the error. It seems so random, in a loop 3/74 rows give this error. I have verified that the values do exists in the DB range (but that should not be the problem either, because when looking up something random, it does not give a rune-time error, but the result-handle from vlookup contain the error.)
I am trying to write a formula that checks the status and name to be ongoing and joe blogs (in this example), and once finding a match, will identify the oldest date of a ticket raised.
My formula currently includes:
=MIN(IF('Sheet2'!AA:AA="ONGOING",IF('Sheet2'!Q:Q="Joe Bloggs",'Sheet2'!B18:B49)))
I also tried:
=IF((AND(sheet2!$AA:$AA="ongoing", 'Sheet2'!$Q:$Q="Joe Bloggs")), MIN('Sheet2'!B18:B49),"No")
In Column B contains dates. Q contains names, AA contains the status.
At the moment when this runs I get the result '00/01/1990'.
I have done some checks to find the error, and appears to be around the targets name, as when the second formula is tried, the output is "no". The name is definitely in the Q column, and I have completed other formulas including countifs which have worked perfectly fine.
I have done a lot of searching to find nested ifs and min statements to have no joy , would be grateful of any advice / tips. It may be a simple error to some.
Try entering this as an array formula:
=MIN(IF(sheet2!AA:AA="ongoing",IF(sheet2!q:q="Joe Bloggs",sheet2!B:B)))
FYI I found the solution here.
You will have to apply a date format to the result.
Your first formula works well on my data (as below). If I close the formula with ENTER only, I get the result '37128' and if I close the formula with CTRL+SHIFT+ENTER I get the expected result, '25/08/2001'.
Edit: As #FocusWiz said in the comments, the only major difference (other than different column names) between my formula and yours is the the last range in your formula (B18:B49) is a different sized range to the other two, which are referring to full columns.
*This could be solved either by using the same row range for all three column references (AA18:AA49, Q18:Q49, B18:B49) or referencing the full column range for all three ranges (AA:AA,Q:Q,B:B).
This is your formula I'm talking about:
=MIN(IF('Sheet2'!AA:AA="ONGOING",IF('Sheet2'!Q:Q="Joe Bloggs",'Sheet2'!B18:B49)))
And this is the formula in my workbook F7:
=MIN(IF(B:B="ONGOING",IF(A:A="Joe Bloggs",C:C)))
As you can see in the formula editor, squiggly brackets '{}' show around the formula when it has been closed as an array formula.
If that doesn't work for you, please post some sample data with datatypes so we can help figure out what is causing the lookup value to miss the data.
While I like the technique offered by Patrick (I have frequently forgotten an "else" portion of a formula and gotten "false" as a value in a cell but never thought of a use for that...thank you!), I think this question highlights an issue we all can have with array formulas. As girlvsdata indicates, your original formula:
=MIN(IF(Sheet2!AA:AA="ONGOING",IF(Sheet2!Q:Q="Joe Bloggs",Sheet2!B:B)))
(modified above to be more generic for column B) will also work when entered as an array formula.
What likely happened is that somehow the formula got edited and was not re-entered as an array formula.
While I do not dislike array formulas, I do try to avoid them because I have fat fingers and will frequently mess them up by accidentally hitting the wrong key as I am modifying other cells.
Here is an alternative without using an array formula:
=INDEX(LARGE((Sheet2!Q:Q&Sheet2!AA:AA="Joe bloggs"&"ongoing")*(Sheet2!B:B),COUNTIFS(Sheet2!Q:Q,"Joe Bloggs",Sheet2!AA:AA,"ongoing")),1)
What it does is basically create a candidate date value for every row that has "joe bloggs" and "ongoing" which is equal to the date in column B for all such rows. All other rows get a zero candidate date value. The LARGE function takes the smallest nonzero date by counting the n valid candidates with the COUNTIFS function and taking the nth largest such candidate.
I am extracting numerics and dates from a column containing mixed strings as shown in the sample table below.
Subscriber Name
123456789123 null null
null
null null null
5/23/2016
hello
Good Evening
null 6/11/2016
I am using the Array formula entering with CSE:
{=IFERROR(--SUMPRODUCT(MID(0&Q2,LARGE(INDEX(ISNUMBER(--MID(Q2,ROW($1:$25),1))* ROW($1:$25),0),ROW($1:$25))+1,1)*10^ROW($1:$25)/10),"")}
I am getting following results showing 0 in cells with empty or text cells whereas I require it to be empty. I have tried by inserting IFERROR and "--" also but I still get 0 in the cells. What correction is required in the formula. Further I am also open to VBA solution, if someone offers.
When no number is found your formula without the iferror is evaluating to 0 which is why you iferror is not catching anything. You could invert your results twice to cause an error when the results are zero. You know:
=1/BIG_HONKING_FORMULA
will give you a DIV/0! error for cells you want blank. You also know this will screw up the results for the rows you do want! so you could do:
=1/(1/BIG_HONKING_FORMULA)
which should generate an error when your formula is zero and should leave your results untouched for what you want to keep.
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)
I have a drop down list (data validation) that populates other cells using vlookup that pulls data from a separate worksheet. I'd like to include an error message if the field is blank like "No data entered". However, I am getting "0" instead. Here is the formula I used:
=IFERROR(VLOOKUP(ChildName,Children,6,FALSE),"No data entered")
I then changed this to an ISERROR:
=IF(ISERROR(VLOOKUP(ChildName,Children,5,FALSE))=FALSE,"No data entered", VLOOKUP(ChildName,Children,5,FALSE))
This gives the error message appropriately but now my drop down list does not populate the other cells!
What am I doing wrong? Thank you!
Looking at your formulas, I see two noteworthy points:
in the IFERROR you return the 6th column, in the ISERROR, the 5th!
in the ISERROR, you show the error message when something is found, as you say =IF(ISERROR=FALSE,ErrorMsg,...)!
To solve your problem, simply use this formula: =IF(ChildName="","No data entered",IFERROR(VLOOKUP(ChildName,Children,6,0),"Cannot find "&ChildName))
Ah, I see! Check out this question - Have Excel formulas that return 0, make the result blank. It shows all ways.
My favorite is =IFERROR(1/1/VLOOKUP(ChildName,Children,6,0),"No data!"). Only works with numbers though.
Else, use =IF(VLOOKUP(ChildName,Children,6,0),VLOOKUP(ChildName,Children,6,0),"No data!").
To be on the safe side, this version should take care of all potential issues: =IFERROR(IF(VLOOKUP(ChildName,Children,6,0),VLOOKUP(ChildName,Children,6,0),"No data!"),"No data!")