Home > Software design >  How to count values in a column based on condition in another column in google sheet
How to count values in a column based on condition in another column in google sheet

Time:10-30

How can I count number of positive results in column Profit/Loss if only setup is ob? I want to store the result in another cell where I can monitor percentage of my trade based on the setups So for example in this image I would get 2 of 3 trade is successful if setup is ob.


Data sample

Date Profit/Loss Bias Setup
31/10/2022 $1,000.00 Up fvg
01/11/2022 -$200.00 Down ob
02/11/2022 $2,000.00 Up br
03/11/2022 -$150.00 Up mt
04/11/2022 $1,500.00 Up fvg
05/11/2022 $1,500.00 Down ob
06/11/2022 $2,000.00 Up mt
07/11/2022 -$200.00 Down br
08/11/2022 $3,000.00 Down fvg
09/11/2022 -$1,000.00 Down fvg
10/11/2022 $2,000.00 Down ob
11/11/2022 $3,000.00 Up fvg

CodePudding user response:

Use enter image description here

Using Lambda

=LAMBDA(PnL, Setup, TO_PERCENT(COUNTIFS(PnL,">0",Setup,"=ob")/COUNTIFS(Setup,"=ob")))
       (B3:B,D3:D)

enter image description here

Used formulas help
LAMBDA - COUNTIFS - TO_PERCENT

  • Related