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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

If statement doesn't allow to select columns

Hello guys, 

 

I hope you are well. 

 

I have a very simple problem but I wasn't able to fix it. 

 

Indeed, I would like to create a IF statement  like this = IF (And([QT received]=0,[Status]="closed"),0,1). 

 

But DAX doesn't allow me to select a column in the parameters but only measures. 

 

Do you know why ? 

 

Many thanks for your help

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous,

What the 'blank' means? 'blank' text or null value? If you mean the null value, you can use @camargos88 's suggestion. For 'blank' text, you need to change the conditions to compare with 'blank'.

Measure =
VAR qtReceiver =
    SELECTEDVALUE ( 'Table'[QT received] )
VAR _status =
    SELECTEDVALUE ( 'Table'[Status] )
RETURN
    IF ( qtReceiver = "blank" && _status = "Closed", 1, 0 )

BTW, the above formula not suitable to use to compare with summarize row contents. For this scenario, you can try to use the following measure formula:

Measure =
VAR summary =
    SUMMARIZE (
        Table,
        [Name],
        [QT Receive],
        [Status],
        "If statement", IF ( [QT Receive] = "Blank" && _status = "Closed", 1, 0 )
    )
RETURN
    CONCATENATEX ( summary, [If statement], "," )

Regards,

Xiaoxin Sheng

View solution in original post

6 REPLIES 6
Greg_Deckler
Community Champion
Community Champion

Within a measure, you need to wrap a column reference in an aggregator like SUM, COUNT, MAX, MIN, AVERAGE, etc.



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...
Anonymous
Not applicable

Thank you for you quick ansawer @Greg_Deckler  ! 

 

I see but in my case, I don't know how to aggregate.

Indeed I have the data below and I would like to measure IF QT received is Blank and Status closed then 0 otherwise 1.

 

NameQT receivedStatusIf statement 
XblankClosed0
Y1Open1
Z0Open1
Anonymous
Not applicable

Hi @Anonymous,

What the 'blank' means? 'blank' text or null value? If you mean the null value, you can use @camargos88 's suggestion. For 'blank' text, you need to change the conditions to compare with 'blank'.

Measure =
VAR qtReceiver =
    SELECTEDVALUE ( 'Table'[QT received] )
VAR _status =
    SELECTEDVALUE ( 'Table'[Status] )
RETURN
    IF ( qtReceiver = "blank" && _status = "Closed", 1, 0 )

BTW, the above formula not suitable to use to compare with summarize row contents. For this scenario, you can try to use the following measure formula:

Measure =
VAR summary =
    SUMMARIZE (
        Table,
        [Name],
        [QT Receive],
        [Status],
        "If statement", IF ( [QT Receive] = "Blank" && _status = "Closed", 1, 0 )
    )
RETURN
    CONCATENATEX ( summary, [If statement], "," )

Regards,

Xiaoxin Sheng

This worked! Thanks!...

@camargos88 's formula should work. I generally just use MAX instead of SELECTEDVALUE but same kind of thing.



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...

@Anonymous ,

Try creating this measure:

 

Measure =
VAR _qtReceived = SELECTEDVALUE('Table'[QT received])
VAR _Status = SELECTEDVALUE('Table'[Status])

RETURN IF(_qtReceived = BLANK() && _Status = "Closed"; 0; 1)
 
Ricardo


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.

Top Solution Authors
Top Kudoed Authors