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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
angelo2022
Frequent Visitor

Problem with calculating the SUM of a calculated Flag Measure

Hi, 
Could someone help me please with my DAX calculation, it's not working out the way I expect.
I have a number of KPIs and I'm evaluated them against a target and if they meet the target I flag them with 1. 

I want to sum all the KPIs that have met target but when I do they all return 1.   

Ultimately I would like to calculate a percentage of the KPIs that have met the Target.  So in the case below it should be 50% of KPIs have met target.   

 

angelo2022_0-1652659441929.png

 

The KPITargetMet Measure works, but the TargetMetSum isn't working properly.  When I create a percentage it says 100% have made target, which is incorrect. 

 

Here is the DAX code I'm using for the Measures. 

 

KPITargetMet =
VAR KPIType = SELECTEDVALUE(MeasureData[KPITargetDiffDirectionUpper])
VAR KPIMeasure = [Measure]
VAR KPITarget = [Target]
RETURN
IF(KPIType="HIGHER", IF(KPIMeasure >= KPITarget, 1, 0),
IF(KPIType="LOWER", IF(KPIMeasure <= KPITarget, 1, 0),0))

 

TotalKPI = CALCULATE(DISTINCTCOUNT(MeasureData[KPIsCode]))

 

TargetMetSum = CALCULATE(DISTINCTCOUNT(MeasureData[KPIsCode]), FILTER(MeasureData, [KPITargetMet]=1))

 

Hope this make sense. 

Thanks Angelo

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@angelo2022 , KPI Met Target measure

Sumx(Values(Table[KPI Code], if( [KPITargetMet]=1, [TotalKPI] , blank()))

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@angelo2022 , KPI Met Target measure

Sumx(Values(Table[KPI Code], if( [KPITargetMet]=1, [TotalKPI] , blank()))

Hi @amitchandak, That worked great for calculating the percentage for the month, thanks for that.  
But I can't get it to display well in a YTD line chart.   Only displays the current month selected. 
Here is the DAX

KPIYTDPercent =
var YearSelected = SELECTEDVALUE('DimDate'[Year])
VAR KPITotal = [TotalKPICount]
VAR KPIMet = [KPIMetTargetCount]
RETURN
CALCULATE(DIVIDE(KPIMet, KPITotal, BLANK()), FILTER(ALL(DimDate), DimDate[Year] = YearSelected))



Hi @amitchandak, Don't worry about my last question about the YTD.  I've worked it out.  Thanks again mate. 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Top Kudoed Authors