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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
jdubs
Helper V
Helper V

How to write an expression using ISBLANK with 3 possible outcomes?

I want to compare two fields to see if they have data or not and return 3 possible outcomes:

 

e.g.

 

Field 1 CONTAINS DATA but Field 2 DOES NOT CONTAIN DATA = True

Field 1 DOES NOT CONTAIN DATA but Field 2 CONTAINS DATA = False

Neither Field 1 nor Field 2 CONTAIN DATA = 3rd option

1 ACCEPTED SOLUTION
jaideepnema
Solution Sage
Solution Sage

Hi @jdubs ,

Create a calculated column like this:

 

IS Blank Flag = SWITCH(TRUE(),

AND(ISBLANK('Table'[Field 1]),NOT(ISBLANK('Table'[Field 2]))),"Field 2 Available",

AND(NOT(ISBLANK('Table'[Field 1])),ISBLANK('Table'[Field 2])),"Field 1 Available",

AND(ISBLANK('Table'[Field 1]),ISBLANK('Table'[Field 2])),"Both Field Not Available",

AND(NOT(ISBLANK('Table'[Field 1])),NOT(ISBLANK('Table'[Field 2]))),"Both Field Available",BLANK())

This will give you the desired result

jaideepnema_1-1614714113951.png

 

 

Please accept this as a solution if your question has been answered !!

Appeciate a Kudos 😀

View solution in original post

3 REPLIES 3
jdubs
Helper V
Helper V

Thank you!

PhilipTreacy
Super User
Super User

Hi @jdubs 

 

Download sample PBIX with code

 

With 2 fields to check you have 4 possible combinations so you need to specify what the result is if both Field1 and Field 2 have data.

In the following code the case where both fields have data results in the default result.

This code creates a measure.  Its better to use a measure than a calculated column in almost all cases.

Compare Fields = 

VAR _Field1 = SELECTEDVALUE('Table'[Field 1])
VAR _Field2 = SELECTEDVALUE('Table'[Field 2])

RETURN

SWITCH(

    TRUE(),

    AND(NOT(ISBLANK(_Field1)), ISBLANK(_Field2)), "True",

    AND(ISBLANK(_Field1), NOT(ISBLANK(_Field2))), "False",

    AND(ISBLANK(_Field1), ISBLANK(_Field2)), "3rd option",

    "Default"

)

    

compfild.png

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


jaideepnema
Solution Sage
Solution Sage

Hi @jdubs ,

Create a calculated column like this:

 

IS Blank Flag = SWITCH(TRUE(),

AND(ISBLANK('Table'[Field 1]),NOT(ISBLANK('Table'[Field 2]))),"Field 2 Available",

AND(NOT(ISBLANK('Table'[Field 1])),ISBLANK('Table'[Field 2])),"Field 1 Available",

AND(ISBLANK('Table'[Field 1]),ISBLANK('Table'[Field 2])),"Both Field Not Available",

AND(NOT(ISBLANK('Table'[Field 1])),NOT(ISBLANK('Table'[Field 2]))),"Both Field Available",BLANK())

This will give you the desired result

jaideepnema_1-1614714113951.png

 

 

Please accept this as a solution if your question has been answered !!

Appeciate a Kudos 😀

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.