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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Ybam
Helper I
Helper I

Calculate with conditions

Hi , 
I have a table like this :

KPI IDValueVersion
110V1
19V1
15V2
23V1
24V1
37V1
46V1
46V2
515V1
512V1
5100V2

 

I create a measure because data for KPI = 5 are not in the good aggregation. 
Measure= 
VAR _A = 
CALCULATE (
   SUM(Value),

   KPI <>5
   && Version = "V1"

)
VAR _B =
DIVIDE ( 

CALCULATE (
   SUM(Value),
   KPI =4
   && Version = "V1"

), 

CALCULATE (
   SUM(Value),
   KPI IN {1, 2, 3}
   && Version = "V1"

)


RETURN 

    IF (
        Max(KPI)= 5,
        _B
        , _A
    )
My result : 
KPIMeasure
119
27
37
46
5

 

 

Desired result :

KPIMeasure
119
27
37
46
50.18

 

Can you help me?

2 REPLIES 2
Greg_Deckler
Community Champion
Community Champion

@Ybam When KPI is 5, the other KPI numbers are not in context so you need to use ALL or ALLSELECTED to bring them back into context like this:

Measure= 
VAR _A = 
CALCULATE (
   SUM(Value),
   KPI <>5
   && Version = "V1"

)
VAR _B =
DIVIDE ( 

CALCULATE (
   SUM(Value),
   ALL('Table'),
   KPI =4 && Version = "V1"

), 

CALCULATE (
   SUM(Value),
   ALL('Table'),
   KPI IN {1, 2, 3} && Version = "V1"

)

) 
RETURN 

    IF (
        Max(KPI)= 5,
        _B
        , _A
    )


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler Thank you very very mutch it works.
But if I want to slipt result my month I have only total .
I would like my result loolks like this. 

Month Jan.FebMarch....
KPIMeasureMeasureMeasure 
11955 
27105 
3778 
4693 
50.180.410.17 

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.