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
Trist
Frequent Visitor

IF Issue in Measure

Hello Everybody, how are you? 

ı have question about writing a row context dax in a ıf clause . 

ı want to wrıte this query(*1) ınsıde of this query(*2). how to do that do u think?

 

*1:  

IF    A[X]="H"

THEN A[Y]*A[Z]*(-1)
ELSE IF A[X]="S"

THEN A[Y]*A[Z]
ELSE 0

-- A= TABLE NAME. X,Y,Z COLUMN NAME.

NOTE: I TRYED SWITCH FX BUT IT DOESNT WORKED.

*2: 

Values =
IF( ISBLANK( [Day] ), BLANK(), ---HERE İS GONNA BE SUM OF FORMULA(*1) ---- ))
-- Values is measure. 
Thanks,
 
2 REPLIES 2
Anonymous
Not applicable

Hello @Trist 
You can try this
Measure 1 =
IF (
ISBLANK ( [Day] ),
BLANK (),
IF ( A[X] = "H", A[Y] * A[Z] * ( -1 ), IF ( A[X,] = "S", A[Y] * A[Z], 0 ) )
)

edhans
Super User
Super User

SWITCH will work. You shouldn't name your measure VALUES - that is a function in DAX. Call it something else. 

 

New Measure =
IF(
    ISBLANK( [Day] ),
    BLANK(),
    SWITCH(
        TRUE(),
        A[X] = "H",
            A[Y] * A[Z] * ( -1 ),
        A[X,] = "S",
            A[Y] * A[Z],
        0
    )
)

 




 

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

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.