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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Rnaval
Helper V
Helper V

Need help with an If statement

I have a matrix, and for one of the columns I would like to use either of two fields, whichever is not blank. Is there a way to do that?

1 ACCEPTED SOLUTION
v-tsaipranay
Community Support
Community Support

Hi @Rnaval ,

Thanks for reaching out to the Microsoft Fabric Community.

 

Since you're working with a matrix visual and want to show the value from either Field1 or Field2 (whichever is not blank), the approach shared by @pankajnamekar25  is correct and best suited for this scenario.

You can use the following measure:

Display Value =

COALESCE(

    SELECTEDVALUE(Table[Field1]),

    SELECTEDVALUE(Table[Field2])

)

To use this:

  • Go to Modeling > New Measure, paste the formula, and add the measure to your matrix.

This will display Field1 when available, and fall back to Field2 when it’s blank exactly as intended.

 

If this post helps, then please give us Kudos and consider Accept it as a solution to help the other members find it more quickly.

 

Thankyou.

View solution in original post

7 REPLIES 7
v-tsaipranay
Community Support
Community Support

Hi @Rnaval ,

Thanks for reaching out to the Microsoft Fabric Community.

 

Since you're working with a matrix visual and want to show the value from either Field1 or Field2 (whichever is not blank), the approach shared by @pankajnamekar25  is correct and best suited for this scenario.

You can use the following measure:

Display Value =

COALESCE(

    SELECTEDVALUE(Table[Field1]),

    SELECTEDVALUE(Table[Field2])

)

To use this:

  • Go to Modeling > New Measure, paste the formula, and add the measure to your matrix.

This will display Field1 when available, and fall back to Field2 when it’s blank exactly as intended.

 

If this post helps, then please give us Kudos and consider Accept it as a solution to help the other members find it more quickly.

 

Thankyou.

Ok I got it working. Thanks. However, it seems I cannot use this "Display Measure" in a card, is there any way around this? Do I need to create a new custom column instead?

Actually, I added a column and then all works fine now. Thanks...

bhanu_gautam
Super User
Super User

@Rnaval 

You can create a new column with the following DAX formula:

NewColumn = IF(NOT(ISBLANK([Field1])), [Field1], [Field2])




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






I get an error message regarding the "IF" expression

pankajnamekar25
Super User
Super User

Hello @Rnaval 

 

use below code dax

Display Value =
COALESCE(
SELECTEDVALUE(Table[Field1]),
SELECTEDVALUE(Table[Field2])
)

 

Thanks,
 Pankaj Namekar | LinkedIn

If this solution helps, please accept it and give a kudos (Like), it would be greatly appreciated.

Where would I enter this code?

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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