Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
water-guy-5
Helper III
Helper III

Creating a measure to find % of an if statement

Hello, I have some data that looks like this
Comp Report Q.png

 

Column A: expected $ amount
Column B: actual $ amount

My third column (Red Flag) is a calculated column that returns "Below Limit" when Column B is less than 75% of Column A, and looks like this (sometimes the columns are blank, hence my rather complicated expression for such a simple calculation)


Red Flag=
Var _A = Table[Actual]
Var _B = Table[Expected] * .75

return
IF( Table[Actual] = BLANK(), BLANK(),
IF( _A < _B, "Below Limit", BLANK()))

I am looking to write a measure that divides the amount of times "Below Limit" appears versus the total # of rows for the Red Flag calculated column, eseentially getting a % ratio for below versus all. 

Thanks in advance.
1 ACCEPTED SOLUTION
water-guy-5
Helper III
Helper III

I figured out a solution, and just posting here in case anyone is in a similar spot. 

I created another column that solves for the other result (when Actual is > 75% of Expected) that returns "Safe"

From there, I wrote this measure

Red Flag % =
Var _Below = CALCULATE(COUNT(Table[Red Flag]), Table[Red Flag] = "Below Limit")
Var _Safe = CALCULATE(COUNT(Table[Safe]), Table[Safe] = "Safe")
Return
DIVIDE(_Below, _Safe)



View solution in original post

1 REPLY 1
water-guy-5
Helper III
Helper III

I figured out a solution, and just posting here in case anyone is in a similar spot. 

I created another column that solves for the other result (when Actual is > 75% of Expected) that returns "Safe"

From there, I wrote this measure

Red Flag % =
Var _Below = CALCULATE(COUNT(Table[Red Flag]), Table[Red Flag] = "Below Limit")
Var _Safe = CALCULATE(COUNT(Table[Safe]), Table[Safe] = "Safe")
Return
DIVIDE(_Below, _Safe)



Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

Find out what's new and trending in the Fabric community.

Top Kudoed Authors