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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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