How can I SUMIF with horizontal and vertical criteria (including dates)? - google-sheets

I'm trying to SUMIF data based on two criteria:
The title of the column (horizontal)
In between two dates (vertical)
I have tried a number of functions to solve this problem but to no avail.
I have tried functions with Match, Index, and Filter, but I couldn't make the function work.
As you can see in my code, I have found a workaround, but it is not ideal as it does not use the table header to identify the data values I'm looking for (see example function below for Product A).
=SUMIFS(B:B,A:A,">="&A$2,A:A,"<="&A$5)
I'm hoping for a function that can dynamically grab the values I'm looking for, based on the table header and the dates.
Thank you for any help you may provide.

You can also use index/match to select just the relevant column of the range (where a zero in the row parameter indicates the entire column):
=sumifs(index($B2:$D,0,match(F1,$B1:$D1,0)),$A2:$A,">="&$A2,$A2:$A,"<="&$A5)

=ARRAYFORMULA({B1:D1; TRANSPOSE(MMULT(
TRANSPOSE(FILTER(B2:D, A2:A>=A3, A2:A<=A5)),
TRANSPOSE(SPLIT(REPT(10,
COUNTA(FILTER(B2:B, A2:A>=A3, A2:A<=A5))), 1))^0))})

My Data
Summary Required :
enter image description here
Formula : =SUMIFS(INDIRECT("C"& MATCH(B15,$B$2:$B$10,0)+1 & ":" & "G"& MATCH(B15,$B$2:$B$10,0)+1),$C$1:$G$1,">="&DATE(2022,2,1),$C$1:$G$1,"<="&DATE(2022,2,28))

Related

How can I sort a column horizontally into transposed rows with matching prefixes?

I have a google sheet column with data that looks like this. ID numbers with count suffixes. How can I transpose them horizontally into rows on a sheet sorted/grouped/filtered by their ID number into the appropriate number of columns matching their suffix number?
Sheet Link:
https://docs.google.com/spreadsheets/d/1wq3Zrh5wE_IHP2utvMeFRHrMe1qra2ppq_G7PrSt-jY/edit?usp=sharing
What I have
INV46673-1
INV46673-2
INV56184-1
INV56184-2
INV56184-3
INV56184-4
INV56184-5
INV68328-1
INV68328-2
INV68328-3
INV68328-4
INV68347-1
INV68347-2
INV68347-3
What I need
INV46673-1
INV46673-2
INV56184-1
INV56184-2
INV56184-3
INV56184-4
INV56184-5
INV68328-1
INV68328-2
INV68328-3
INV68328-4
INV68347-1
INV68347-2
INV68347-3
If sheets has an off the shelf function for this I have not been able to find it. I have tried pivot tables, Hlookup, filtered arrays etc. I am grateful for any advice I may receive. A solution that uses a fixed character count (8) will work but I would love to see something that actually uses the exact ID number.
Try the following formula-
=INDEX(SPLIT(BYROW(UNIQUE(INDEX(SPLIT(A2:A15,"-"),,1)),LAMBDA(x,JOIN("|",SORT(FILTER(A2:A15,INDEX(SPLIT(A2:A15,"-"),,1)=x))))),"|"))
Here's another approach:
=index(let(a,regexextract(A2:index(A:A,counta(A:A)),"(.*)-(\d+)"),b,unique(index(a,,1)),c,max(--index(a,,2)),makearray(counta(b),c,lambda(r,x,xlookup(index(b,r)&"-"&index(sequence(1,c),,x),A:A,A:A,)))))

How to check multiple ranges for different values in Google Sheets

I'm trying to search 3 different ranges in a tab, and trying to display Yes if all three values (email address, name, x) are found in those ranges. Basically, trying to have the formula confirm that yes, all three of those inputs are somewhere in those ranges (order doesn't matter).
Maybe I should use query or regexmatch or something? Any help is appreciated
Tried this formula:
=IF(AND('Helper Calculations'!$I:$I=$A$1,'Helper Calculations'!$J:$J=L$1,'Helper Calculations'!$L:$L=$A2),"Yes","No")
Was expecting that if the search term in each of those cells ($A$1, L$1, $A2) is found somewhere in the corresponding ranges, then it would say Yes
You can try with this (you can change the use of asterisks by wrapping in AND:
=IF(COUNTIF('Helper Calculations'!$I:$I,$A$1)*COUNTIF('Helper Calculations'!$J:$J,L$1)*COUNTIF('Helper Calculations'!$L:$L=$A2),"YES,"NO")
try:
=INDEX(IF(('Helper Calculations'!I:I=A1)*
('Helper Calculations'!J:J=L1)*
('Helper Calculations'!L:L=A2), "Yes", "No"))
Took a bit more work than I expected, but I got this working. I needed to verify that all 3 values were correct in a single row (must all be correct on that one row, can't find the correct values on multiple rows).
In order to do that, I needed to use array formula, and then decided to use index match and concatenate for the 3 values.
Process described here: https://www.ablebits.com/office-addins-blog/google-sheets-index-match/
correct formula: =IF(ArrayFormula(INDEX('Helper Calculations'!$I:$I,MATCH(CONCATENATE($A$1,L$1,$A2),'Helper Calculations'!$I:$I&'Helper Calculations'!$J:$J&'Helper Calculations'!$L:$L, 0),))=$A$1,"Y"))

How to make a relative reference in an array formula in Google Sheets

Here's the straightforward version of my question:
I want to change the following formula to an array formula...
Original formula (from cell J2):
=if(F4="VM:",G4,J1)
My attempt at converting to an array formula (in cell K1):
=arrayformula(if(row(A:A)=1,G3,if(F:F = "VM:",G:G,indirect("K"&row(A:A)-1))))
This works on rows where F = "VM:", but returns a #REF error on other rows. Function INDIRECT parameter 1 value is 'K0'. It is not a valid cell/range reference.
Thoughts on how to fix this?
The more complex version of my question. i.e. Why am I trying to do this?...
I have a weird spreadsheet with data that should really be in a Wiki.
I want to create filter views for each person so they can easily filter on only their own vendors. The original formula will work, but as more vendors are added, I'd like for the formula to automatically work for those rows as well.
If there's a better way to do this, I'm listening.
I don't exactly understand your needs, but If you want to autopopulate your formula, then you only need this code in desire column in row 4 (you can change this to any other - this will autofill down from this point):
=ArrayFormula(if(F4:F="VM:",G4:G,J1:J))
Is this what you are trying to get?
After clarification:
You need this code in J2 only:
=ArrayFormula(VLOOKUP(ROW(J2:J),
QUERY({F:G,ROW(G:G)},"select Col3,Col2 where Col1='VM:'",1)
,2,1)
)
Works for you?
maybe you just need to hide errors?
=IFERROR(ARRAYFORMULA(IF(ROW(A:A)=1,G3,IF(F:F = "VM:",G:G,INDIRECT("K"&ROW(A:A)-1)))),)

Filter unique values based on secondary attribute

I've filtered unique values (discarding blanks) from one sheet to another. I'd now like to add the equivalent of an 'if' to display unique values that also have a value attached to it.
To illustrate my point I've highlighted the values (green) of the values I'd like to carry through.
My current formula:
=UNIQUE(FILTER('Sheet2'!A1:A33,'Sheet2'!A1:A33<>""))
The working sheet(s) can be found here. I figured it's be easier than describing it in text.
https://docs.google.com/spreadsheets/d/1svoiYRZA0VP76HEjWYmJWd_j57Qf5HOHXNDlnpjfkqM/edit?usp=sharing
The formula in question is in cell A1 on Sheet1.
Thanks in advance.
You can add that condition in your filter function.
=UNIQUE(FILTER(Sheet2!A1:A33,Sheet2!A1:A33<>"", Sheet2!B1:B33>0))
If you want to return name AND value, try
=UNIQUE(FILTER(Sheet2!A1:B33,Sheet2!A1:A33<>"", Sheet2!B1:B33>0))
=FILTER(Sheet2!A:G,Sheet2!A:A=UNIQUE(Sheet2!A:A))
for my case,
unique column A,
bring along value B to G.

Google Spreadsheet Function That Sums Numbers In A Column When the Row Contains An EXACT Text

I've been at this problem for a while now. I am trying to sum numbers under a specific column when the rows equal a certain text and then display that sum on a different sheet. So far I came up with this formula: =IF(EXACT(A2,Table!A2:A)=TRUE,SUM(Table!C2:C)); however the only problem is that is sums everything in column C (which makes sense).
I wish there was a way to do something like the following: SUM(Table!C2:C where EXACT(A2,TABLE!A2:A)=TRUE). I've also tried the SUMIF(), DSUM(), and QUERY() functions to no avail. I must be getting logically tripped up somewhere.
Figured it out: =SUM(FILTER(Table!E4:E, EXACT(Table!A4:A,A4)=TRUE)).
=sum ( FILTER (b1:b10, a1:a10 = "Text" ) )
// the above formula will help you to take the sum of the values in column B when another column A contain a specific text.
The formula is applicable only in Google Spreadsheets

Resources