I cannot find a simple answer to this, sorry if this is super obvious.
I have a table:
A B
1 Fruit: Rotten?
2 Apple TRUE
3 Banana FALSE
4 Apple FALSE
5 Apple TRUE
Now I would like to have the formula for:
=COUNT(of rotten Apples in range A2:B5)
Any help would be appreciated.
This is pretty straight forward, you use COUNTIFS with multiple criteria
=COUNTIFS(A2:A5; "Apple"; B2:B5; TRUE)
Related
I have an spreadsheet like this:
product name
sold?
banana
FALSE
banana
TRUE
apple
TRUE
apple
FALSE
apple
FALSE
I'd like to add another column to display the number of unsold products. so the desired result would be something like this:
product name
sold?
available
banana
FALSE
1
banana
TRUE
1
apple
TRUE
2
apple
FALSE
2
apple
FALSE
2
Thanks.
You need COUNTIFS(). Try-
=COUNTIFS($A$2:$A,A2,$B$2:$B,FALSE)
For dynamic spill result, use MAP() function.
=MAP(A2:A6,LAMBDA(x,COUNTIFS(A:A,x,B:B,FALSE)))
To refer full column as input, use-
=MAP(TOCOL(A2:A,1),LAMBDA(x,COUNTIFS(A:A,x,B:B,FALSE)))
apologies for the very basic question but I've created a home-made expenses tracker on Google Sheet just for fun and to improve my skills but I'm struggling to make this formula work.
In tab 1 I have a calendar that looks like this:
In tab 2 I have all my transactions:
My idea was to use sumifs in tab 1 so that for the earnings I can sum all transactions that were done in December 2022 and define that all amounts need to be greater than 0, similarly, for the expenses, all transactions would be less than 0.
I did try this formula which obviously doesn't work as I don't know how to specify whether transactions need to be greater or less than 0:
=SUMIFS(transactions!$D:$D,transactions!$A:$A,$B3,transactions!$D:$D,transactions!D3>0)
I'd really appreciate your help, thank you!
try:
=SUM(FILTER(transactions!D:D, transactions!A:A=B3, transactions!D:D>0))
or:
=BYROW(B3:B11, LAMBDA(x, SUM(
FILTER(transactions!D:D, transactions!A:A=x, transactions!D:D>0))))
I have this google sheets input.
Players
Loot
Player1
4
Player2
4
Player3
5
Player4
2
What I'm attempting to do is simplify this formula in order to get TRUE in a single cell.
=OR(B2>=5,B3>=5,B4>=5,B5>=5)
This is what i did so far.
=ArrayFormula(SUM((B2:B5*1>=5)*1))>0
Can this formula be simplied further and still get TRUE in a single cell when one of Loot values is >= 5?
COUNTIFS() may give you desired result. Try-
=COUNTIFS(B2:B5,">=5")>0
Select the entire range B2:B5 and check if it's greater than 5 using >=. >= operator supports arrays. OR merges the values to a single cell.
=ARRAYFORMULA(OR(B2:B5>=5))
AND can be used in a similar way.
How can I automate my scoring formula to count odd rows as 1 for TRUE and even rows as 1 for FALSE?
Backstory
I'm trying to import a quiz that I found in the back of an ancient, eldritch tome into G Sheets. The order of the questions is fixed - the notes in the margins are very specific that a "dire fate" awaits anyone who "dares disturb these ancient mysteries." So I'm putting the questions in G Sheets in order, but in order to count the scores, I need to have every odd row give +1 if the answer is TRUE and every even row give +1 if the answer is FALSE.
Row Number
Question
Answer
Score
1
Dread Cthulhu is my personal Lord and Slayer
TRUE
1
2
Men are destined to master their own fates
FALSE
1
3
This way is madness
TRUE
0
4
These secrets should have stayed buried
FALSE
0
I know I could brute force this with addition, such as
=COUNTIF(C2,TRUE)+COUNTIF(C4,TRUE)+COUNTIF(C6,TRUE)...
but every minute I spend typing, I feel the tendrils of existential dread gnawing at the foundations of my soul. Plus, that sounds super-boring.
So, is there a way to automate having COUNTIF() (or COUNTIFS()) do this for me?
Things That I Have Tried or Thought About
ROW(), but it doesn't seem to play nice with COUNTIFS(), just gives me a 0.
=COUNTIFS(C2:C666,TRUE,A2:A666,ISEVEN(ROW)
Adding a cheater-column that does this for me with ROW(), but I'm worried that tinkering with the table will unleash untold horrors on our world.
Maybe something with DCOUNT or ARRAYFORMULA? But those seem to me MORE forbidden than the Necronomicon, not less.
Did try this, but it's just giving me the total number of true values:
=ARRAYFORMULA(COUNTIFS(A3:A24,ISEVEN(ROW()),A3:A24,TRUE))
What else y'all got?
=ARRAYFORMULA(ABS(C3:C-ISEVEN(ROW(C3:C))))
UPDATE:
To get the total:
=SUMPRODUCT(ABS(C3:C-ISEVEN(ROW(C3:C))))
Matt's formula looks like the way to go. Try this to get the total:
=arrayformula( sum( islogical(C3:C) * abs(C3:C - iseven(row(C3:C))) ) )
say I have the following table
1 apple
2 banana
2 apple
3 banana
With COUNTIF(B1:B4;"banana") I would get 2, but I'm searching for a formular that respects the mulitplier to get 5 as result. Is this possible?
Use sum if:
=SUMIF(B1:B4;"banana";A1:A4)
First range to search
Seccond the search item
Third The range for the sum