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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Ah_saaah01
Helper I
Helper I

get rid of space in IF function

Hi I hope someone could have better solution to this:) 

 

option 1....20  in the columns, here is the DAX I used to get a description text combination based on the options

If option1>xx, "option 1", ""

& If option 2>yy, "option 2", ""

& If option 3>zz, "option 3", ""

.......

Eventually, I hope to have text like "option 2 option3 option4....."

The problem is "", which is used to generate space between text, however, in cases where option 1 and option 2 for example are not chosen, the text would be "   option 3 option 4". It leaves spaces for those options that are false. what should I include in false condition to make it disappear? How can I modify the DAX when in false condition, it ignores the option without adding space and continues with the next if text output? Thank in advance. 

1 ACCEPTED SOLUTION
AllisonKennedy
Super User
Super User

@Ah_saaah01 

 

What's the format of your data and are you wanting a measure or column? 

 

You can try using concatenatex and filter: 

 

Measure 2 =
VAR _val = 2
VAR _val2 = 6
VAR _table =
{
IF(1 > _val, "Option 1"),
IF(2 > _val2, "Option 2"),
IF(3 > _val, "Option 3"),
IF(4 > _val2, "Option 4"),
IF(5 > _val, "Option 5"),
IF(6 > _val2, "Option 6"),
IF(7 > _val, "Option 7"),
IF(8 > _val2, "Option 8")
}
RETURN

CONCATENATEX(
    FILTER(_table, [Value] <> BLANK()), [Value], ", ")

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

View solution in original post

2 REPLIES 2
AllisonKennedy
Super User
Super User

@Ah_saaah01 

 

What's the format of your data and are you wanting a measure or column? 

 

You can try using concatenatex and filter: 

 

Measure 2 =
VAR _val = 2
VAR _val2 = 6
VAR _table =
{
IF(1 > _val, "Option 1"),
IF(2 > _val2, "Option 2"),
IF(3 > _val, "Option 3"),
IF(4 > _val2, "Option 4"),
IF(5 > _val, "Option 5"),
IF(6 > _val2, "Option 6"),
IF(7 > _val, "Option 7"),
IF(8 > _val2, "Option 8")
}
RETURN

CONCATENATEX(
    FILTER(_table, [Value] <> BLANK()), [Value], ", ")

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Super, sorry for the late reply, but this is really helpful. I could use it in my report. You are the real expert! Thank you very much

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

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

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.