PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, November 3, 2022

[FIXED] How to count values in a column based on condition in another column in google sheet

 November 03, 2022     countif, google-sheets, lambda, percentage     No comments   

Issue

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

Solution

Use Countifs() function.
To get the percentage of the number of Profit/Loss values > 0 and setup = "ob" Divided by the count of instances of setup = "ob".

=COUNTIFS(B3:B,">0",D3:D,"=ob")/COUNTIFS(D3:D,"=ob")

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



Answered By - Osm
Answer Checked By - Robin (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing