Seyma Kalay
Seyma Kalay

Reputation: 2861

IF else in Calculate in Dax

I have a simple calculation MyBase = SUM('MyData'[Amount]) and I would like to include an ifelse statement in Calculate. The condition is IF [Currency Type] = "USD" THEN [MyBase]/2 Otherwise print out the code below.

MyCalculate = 
CALCULATE(    
    [MyBase],
    KEEPFILTERS('MyData'[Currency] = "USD"),
    KEEPFILTERS('MyData'[Scenario] = "AOP")
    )

Upvotes: 1

Views: 152

Answers (1)

davidebacci
davidebacci

Reputation: 30304

IF(
'MyData'[Currency] = "USD", 
[MyBase]/2, 
CALCULATE(    
    [MyBase],
    KEEPFILTERS('MyData'[Currency] = "USD"),
    KEEPFILTERS('MyData'[Scenario] = "AOP")
    )
)

Upvotes: 1

Related Questions