How do I use XLOOKUP for multiple criteria? - google-sheets

my question is simple enough. It involves, using XLOOKUP formula. So, following is the issue, I'm facing.
I have master data sheet, which I'm using for the lookup reference.
In sheet XLOOKUP test, I'm looking up the Task Completion Status for the search keys Sl No. in cell C3 and Date in cell C4.
I've applied the formula-
XLOOKUP($C$3&$C$4, 'Master Data'!$A$2:$A$9&'Master Data'!$C$2:$C$9, 'Master Data'!$D$2:$D$9, , 0, 1)
But, it pops out an #N/A error message with Array arguments to XLOOKUP are of different size..
So what am I doing wrong ?
Here's a link to my sheet, if needed.

To combine columns into a compound key, you need to wrap the formula in arrayformula(), like this:
=arrayformula( xlookup(C3 & C4, 'Master Data'!A2:A9 & 'Master Data'!C2:C9, 'Master Data'!D2:D9) )
Alternatively, use filter():
=filter('Master Data'!D2:D9, C3 = 'Master Data'!A2:A9, C4 = 'Master Data'!C2:C9)
See your sample spreadsheet.

Related

Summing specific values in a joined list

I am having some difficulties summing up some values in Google Sheets. In my spreadsheet, from multiple other tabs, values and bonuses are combined into one cell (Cell B1 in this example). The format of each "unit" of data is Name,5%xxx (Where "Name" is the name of the item, "5%" represents the sum I want to add, mostly always a percentage, and "xxx" separates one unit from the next). As you can see in cell B1, there are two instances where "Parkour" receives a bonus to sum up (from different sources).
Parkour,5%xxxParkour (Subskill: Sense of Balance),10%xxxParkour,2%xxx
Parkour
0.07
Parkour (Subskill: Sense of Balance)
H2H Combat: Parkour
The formula in cell B2 is:
=IFERROR(SUM(ARRAYFORMULA(IFERROR(VALUE(MID(FILTER(SPLIT(TEXTJOIN("",TRUE,filter(B$1,regexmatch(B$1,$A2)=TRUE)),"xxx"),SEARCH($A2,SPLIT(TEXTJOIN("",TRUE,filter(B$1,regexmatch(B$1,$A2)=TRUE)),"xxx"))),len($A2)+2,1000)),""))),"")
(Dragged down through the rest of the list) (Could not figure out how to make the formula "in line" on the question.)
Expected Results:
B2 = .07 (Working)
B3 = .1 (Not working)
B4 = Blank (Working)
The goal of the formula is to look into cell B1, and split everything out by "xxx". Then, filter the array of items with only exact matches with the line item in column A, then split again by the comma and add up those values. It worked for the first line item, but not the second. (Unsure why, but I strongly believe it has something to do with the parenthesis. When I removed the parenthesis from the name in Column A (and adjusted cell B1 to not have parenthesis), it worked. However, given the structure of the data, parenthesis are required, and I need to find a way for it to work with them.)
When I removed the IFERROR wrap around it in cell B3, I get this error note:
Function SUM parameter 1 expects number values. But " is a text and cannot be coerced to a number.
Any help is greatly appreciated.
You may find useful combining SPLIT with QUERY like this. It will group names and sum percentages:
=QUERY(INDEX (IFERROR(SPLIT(FLATTEN(INDEX(SPLIT(B1:B100,"xxx"))),","))),"SELECT Col1,SUM(Col2) where Col1 is not null group by Col1")
PS: invented a couple of extra line
UPDATE
I've thought you had another goal, try this formula. Having the previous chart generated by QUERY, I used VLOOKUP to match first column and return second one:
=INDEX(IFERROR (VLOOKUP(A2:A,QUERY(INDEX (SPLIT(FLATTEN(SPLIT(B1,"xxx")),",")),"SELECT Col1,SUM(Col2) where Col1 is not null group by Col1"),2,0)))

ARRAYFORMULA is only populating the first row

I have financial data that I am trying to summarize in a format that can be used by a line chart.
The example spreadsheet is here.
In my source data on the left, I have an entry per Date, Symbol, Account. I need to transform this data so there is a row per Date and a column for each Symbol. I will SUM Total Value regardless of account.
I found a way to pull a unique Date (see H2), and then transpose unique Symbols into columns (see I1).
I also found a way to use SUMIFS to get the aggregation I want (take a look at cell I2), but I can't figure out how to use ARRAYFORMULA to apply this value to all rows in column I.
I know I can drag my formula from I2 down to I3,I4,I.. etc, but this sheet is part of a larger project so I'd like it to auto-populate as dates are added to H.
From what I've read ARRAYFORMULA should apply the formula to multiple rows. What am I missing?
Thanks
use:
=QUERY(A1:F, "select A,sum(F) where A is not null group by A pivot B", 1)
Use formulas like this
=ARRAYFORMULA(IF(H2:H="",,SUMIFS($F$2:$F, $A$2:$A, $H2, $B$2:$B, I$1)))
Add IF(H2:H="",,
Explanation
if the range is empty "" do nothing ,, else Your formula
Your Example
Cells
Formulas
I2
=ARRAYFORMULA(IF(H2:H="",,SUMIFS($F$2:$F, $A$2:$A, $H2:H, $B$2:$B, I$1)))
J2
=ARRAYFORMULA(IF(H2:H="",,SUMIFS($F$2:$F, $A$2:$A, $H2:H, $B$2:$B, J$1)))
K2
=ARRAYFORMULA(IF(H2:H="",,SUMIFS($F$2:$F, $A$2:$A, $H2:H, $B$2:$B, K$1)))

Query function not working beyond column Y

I'm using the Query function to pull a list of job names from a different sheet that meet certain criteria. The sheet that has the data that I am pulling the list from has 28 columns. When I try to use Column Z, AA, or AB I get the error saying that Query completed with an empty output. I know this to be false. I've tried playing with the headers and naming the columns like this: Col1,Col2 etc. to no avail. Here is a simplified version of my formula:
=Query('Job Details'!$B$1:$AB,"Select B where AA<95",1)
Why does the query come up with an empty return when I use the above formula when I know that is should not?
This formula works just fine:
=Query('Job Details'!$B$1:$AB,"Select B where I<95",1)
Here's a link:
https://docs.google.com/spreadsheets/d/1C4NSCOHjaaCrn1Cm03DTTNcepmwzQEU4Lz_9bL-Sp5w/edit?usp=sharing
All personal data has been changed. The problem formula is highlighted green in the "Job est" sheet.
Any help is greatly appreciated!!
Aaron

Looking for workaround where Google Sheets QUERY function turns numbers into text . .

I've been researching all morning and haven't been able to find a way to make this work. Example Spreadsheet I have a form (created as a student test) that feeds a spreadsheet with 160+ questions; therefore columns. I'm using a transpose/query function to bring the data into another tab so I can begin the analysis. The problem is, when the data comes into the new tab =query(transpose(query('Form Responses 1'!$A$2:$FF$2,"Select *",1))), it turns all the numeric scores into text. I believe it does this because there are string values as well. I would like to filter those out, but no luck there either. Does anyone know of a work-around for this? Or can recommend a better way? THANK YOU!
I'm not sure what you're trying to do exactly, but if you just want to transpose the 'Form Responses 1' data and convert columns E and F to a numeric, then you could try the following.
Create a new tab called 'Cleaned'.
In cell A1 enter ={'Form Responses 1'!A1:FN1}
or to remove 'Option ' from the headings:
=arrayformula(substitute({'Form Responses 1'!A1:FN1},"Option ",""))
In cell A2 enter =arrayformula({'Form Responses 1'!A2:D,value('Form Responses 1'!E2:F),'Form Responses 1'!G2:FN})
Then on your 'Transpose Data' tab, in cell A1, enter:
=transpose(Cleaned!$A$1:$F$5)
In cell A7, enter:
=transpose(Cleaned!$G$1:$FF$5) * see below
Make sure there are no formulas below cell A7 or in columns B to E.
*If you want unique values in the transposed columns A to E, then in cell A7 use:
unique(transpose(Cleaned!$G$1:$FF$5))
If you only want unique values in column A, then you could create another tab, say 'Transpose Data2':
In cell A1:
=unique('Transpose Data'!A:A)
In cell B1:
=arrayformula(iferror(vlookup(A1:A,{'Transpose Data'!A:E},{2,3,4,5,6},false),""))
It won't keep your G1, G2, G3 rows together, but that will need a sort column creating on the 'Transpose Data' tab.

How to use Sumif using range from a complete different Googlesheet/doc

I know how sumif works when I need to access it within the same Google "workbook" (using the analogy from excel). By workbook I mean a collection of sheets, not sure whether there is a different way to refer to Google workbook.
For example in the sheet (Example 3): https://docs.google.com/spreadsheets/d/1Dm-N-1X38zHartE3JbPUtWDnYwEpkGHl6v06huvjSa8/edit#gid=0
I have Sheet2, with column A contain strings and column B containing numerical value. On sheet 1, I have a sumif function which can be query data stored in Sheet2, and sum the cells which match A1 in Sheet1.
The problem starts happening when I try to refer to ranges in a completely different workbook, which is shown below.
I am trying to do a sumif over 2 ranges from a different "workbook". The data is stored here (Example 2): https://docs.google.com/spreadsheets/d/1P5Inf09fLSRmsGbG7LwlE4V-r7DzqY0SB5tJuMKMZH0/edit#gid=0
The Sumif function is in Cell B1 of the following sheet (Example 1):https://docs.google.com/spreadsheets/d/1AitilELd6w7Dbv9d-mKhBYGTBaO6DdkU29Y5mofX2TI/edit#gid=0.
From my understanding importrange is typically used to refer to ranges in completely different workbooks, as a result I use importrange as the first and last arguments in the sumif function in the Sheet Example 1.
What am I doing wrong? Why is this not working?
Can anybody help?
Thanks a lot
See if this query does what you want:
=SUM(query( QUERY( Importrange("1P5Inf09fLSRmsGbG7LwlE4V-r7DzqY0SB5tJuMKMZH0","Sheet1!A1:B10") ) , "select Col2 where Col1 contains '"&A1&"'" ) )

Resources