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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Applicable88
Impactful Individual
Impactful Individual

filter empty fields within true/false column

Hello,

 

I have a table like this:

StatusOrder
True1234
false1235
True1236
false1237
 1238
 1239
 1240

 

I want to make a calculated column this way:

if ( Status=false(), "active", if (status= True(), "inactive", "inactive")

But I simply cannot get "inactive" into the empty cells. Also via the filter panel of the table visual I empty cells in status strangely didn't get filtered out. 

Can I wrap my if statement into a another function to reach that?

Thank you in advance.

Best. 

2 ACCEPTED SOLUTIONS
parry2k
Super User
Super User

@Applicable88 yes it matters, check this post Handling BLANK in DAX - SQLBI

 

Also, you can simply your expression:

 

if ( 'Table'[Flag]==blank() || 'Table'[Flag]= False(), "active",  "inactive")

 

Check my latest blog post Comparing Selected Client With Other Top N Clients | PeryTUS  I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

v-robertq-msft
Community Support
Community Support

Hi, @Applicable88 

According to your description, I can roughly understand your requirement, you want the column value to be “active” when the status is false and “inactive” when the status is true, right? I think you can simply achieve this using the SWITCH() function in DAX, You can try this DAX formula:

Column =

SWITCH(

    [Status],

    FALSE(),"active",

    TRUE(),"inactive",

    "inactive")

 

And you can get what you want.

vrobertqmsft_0-1624433773171.png

 

More info about the SWITCH() function in DAX

 

You can download my test pbix file below

Thank you very much!

 

Best Regards,

Community Support Team _Robert Qin

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

View solution in original post

6 REPLIES 6
v-robertq-msft
Community Support
Community Support

Hi, @Applicable88 

According to your description, I can roughly understand your requirement, you want the column value to be “active” when the status is false and “inactive” when the status is true, right? I think you can simply achieve this using the SWITCH() function in DAX, You can try this DAX formula:

Column =

SWITCH(

    [Status],

    FALSE(),"active",

    TRUE(),"inactive",

    "inactive")

 

And you can get what you want.

vrobertqmsft_0-1624433773171.png

 

More info about the SWITCH() function in DAX

 

You can download my test pbix file below

Thank you very much!

 

Best Regards,

Community Support Team _Robert Qin

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

@v-robertq-msft @parry2k @Anonymous ,

thank you very much. @parry2k , if you woulnd't have mention it, I hardly would know that its better to evaluate blanks first in a nested if - statement. 

In that article I found out  that its also best practice to do so with the switch() function, so it surprised me a bit to see the above example of @v-robertq-msft still fill out "inactive" for the empty cells correctly.

 

Best regards. 

 

 

 

parry2k
Super User
Super User

@Applicable88 yes it matters, check this post Handling BLANK in DAX - SQLBI

 

Also, you can simply your expression:

 

if ( 'Table'[Flag]==blank() || 'Table'[Flag]= False(), "active",  "inactive")

 

Check my latest blog post Comparing Selected Client With Other Top N Clients | PeryTUS  I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

hi @Applicable88 ,

 

Create Calculated column using following logic

 

_Active_Flag = IF(ISBLANK('Table'[Flag]),"Inactive",if('Table'[Flag] = "True", "Inactive","Active"))
 
Thanks!
parry2k
Super User
Super User

@Applicable88 what is the column type of status? is it a boolean or a text?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Thank you, @Anonymous @parry2k ,

Its set on boolean already. 

 

Is the order of a statement in particular important?

This won't work:

if( 'Table'[Flag]= False(), "active", if( 'Table'[Flag]= True(), "inactive", if('Table'[Flag]==blank(), "active"))

 

But strangely that order works, when I check for the empty cells  first: 

if ( 'Table'[Flag]==blank(), "active", if( 'Table'[Flag]= False(), "active", if( 'Table'[Flag]= True(), "inactive"))

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.