Lookup multiple values from one cell - google-sheets

Trying to obtain desired output shown in E:G from a data show in A:C. I can write a formula
JOIN(", ", FILTER($B$2:$B,$C$2:$C=E2,$A$2:$A=F2))
If there would be a single value in F2 I could get comma-separated output items from column B. But I need to do that for more than one value in F2 cell and get the output shown in column G. How to write a formula that can generate column G as desired?
Any help is welcome.

If you're happy with formula dragging down each cell, as per your example in cell F2, then G2 could be:
=join(",",unique(filter({$A:$A&"("&$B:$B&")"},$C:$C=$E2)))
There are more complex formula to do the calcs with an arrayformula.
Within the filter, there are {} brackets that are used to build an array of data. The array consists of Col A then ( then Col B then ).
It then works the same way as per your example in cell F2. The filter finds each row of the array where Col C matches the value in Col E. Unique and join get the results the same way.
When you drag down the formula, textjoin might be more helpful in ignoring empty cells than join.
Use this in cell F2:
=textjoin(",",true,filter(A:A,C:C=E2))
this in cell G2:
=textjoin(",",true,unique(filter(if($A:$A<>"",{$A:$A&"("&$B:$B&")"},),$C:$C=$E2)))
Using arrays in Google Sheets
https://support.google.com/docs/answer/6208276/using-arrays-in-google-sheets?hl=en-GB

Related

Conditional Formatting formula to compare two cells when one cell has a delimiter

So I have in column D QtyInvoiced and in column G QtysSent. For each row, QtyInvoiced is a single number e.g. 50. QtysSent on the other hand is of the delimiter format A_B_C where A,B and C are quantities. In each case, A+B+C would be the Total QtysSent.
How can I write a conditional formatting formula that compares (in the example above), the single value 50 in column D to A+B+C and higlights both cells in the particular row if they are not equal?
I imagine it requires using SPLIT inside the formula but not sure how to construct it to tell Google Sheets to compare the sum after splitting to the value in column D and then highlight both if they are not equal.
try this out:
Custom formula:
=$D2<>SUM(SPLIT($G2,"_"))

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)))

Implement formula in a column based on contents of each cell

In my Google Sheet, I have 1000+ rows of Date entries. For each Date, I am calculating the Month# and Week# using MONTH() and WEEKDAY() functions respectively.
Here is the link to a sample file: https://docs.google.com/spreadsheets/d/1Af5-pYMFWZ1QtLoaAbPZYMGRvk43JBslUp4KyOFADfA/edit?usp=sharing
Problem Statement:
For all rows which have a unique Month# and Week#, I would like to implement a formula and calculate Output. For example, in my sheet, rows 3 to 6 pertain to Month=1 and Week=4. For this set of 5 rows I am calculating Output column as the subtraction from the first element in that set (ie... C3-$C$3, C4-$C$3, C5-$C$3 so on ). Similarly row 7 to 10 pertain to Month=1 and Week=5, and so I calculate Output
as Data-$C$7 and so on.
How do I implement this structure to calculate Output column on each set of unique Month# and Week# values?
Delete everything from Column F (including the F2 header). Then place the following formula into cell F2:
=ArrayFormula({"Output";IF(C3:C="",,IFERROR(C3:C-VLOOKUP(E3:E,{E3:E,C3:C},2,FALSE)))})
This one formula will create the header and return results for all valid rows.
Since VLOOKUP always finds only the first matching instance of what it is looking up, we can use it to ask that each value in C3:C subtract that first instance of where week-number match for each row.
By the way, although you didn't ask about this, you can also use this type of array formula in Columns D and E, instead of all of the individual formulas you have. To do that, delete everything from Columns D and E (including the headers). Then...
Place the following formula in D2:
=ArrayFormula({"Month #";IF(B3:B="",,MONTH(B3:B))})
... and the following formula in E2:
=ArrayFormula({"Week #";IF(B3:B="",,WEEKNUM(B3:B))})

Looking for Google Sheet Array Formula

Hello I'm trying to create a Array Formula for the following B and C columns but getting error,
but without Array Formula the formula works by dragging the formula to all the cells. So I need a Array Formula so I can restrict a formula for specific range, So when I add a new row anywhere in d middle the that row should be working without any formula.
https://docs.google.com/spreadsheets/d/1kc58OkoA3SysApgALJnecnIoK2uyPV6FlhyVRTUXXcI/edit?usp=sharing
So in the above link where there is a list of items in Sheet2 A:
and I importing the list to Sheet1 A: with Array Formula.
Now in D column dropdown list whenever we select an item it keeps removing the used items from C column.
So how to make work while adding Array Formula for B and C Column.
I suggest a complete chage of strategy ... in B1 Sheet2
=arrayformula(countif(Sheet1!D:D,A1:A))
then in C1 Sheet1 (nothing in B1 Sheet1)
=iferror(query(Sheet2!A:B,"select A where A is not null and B=0 "))
the red corner is a good indication that the item is reserved. https://docs.google.com/spreadsheets/d/1m_SACJtoN2k-c1p4C-eflh3pKLmv6YqP8BM2i0jDUhw/edit?usp=sharing

Formula to give itemized sum

I have the following sheet (link). What formula would yield the itemized sums in B2, C2, and D2?
To calculate the value in B2, the formula should check cells B5:B10 and sum the corresponding values from A5:A10 for non-blank cells. Hence: 30+45+30=105.
I have tried ARRAYFORMULA(IF(B5:B10 != ""), sum(A5:A10)) which results in Formula parse error.
Considering that the numbers in column B are not to used (thats what i figured out from your example).
you can use sumIf:
=SUMIF(B5:B10,">0",A5:A10)
so this will check if the cell in column B is greater than 0, then it will add its corresponding value from column A.
please note that if you put a character in the B column the SUMIF will not consider it because we are using ">0" as criterion, instead use ISBLANK.
hope it helps.

Resources