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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
JK-1
Frequent Visitor

IF statement and conditions

Hello, what would be the best way to run both these in DAX within the same statement. Switch / nested?  I can't quite work it through, grateful for pointers as a newbie.

 

Although only 2 conditions (at the moment), and looked at OR || as well, not sure on most appropriate method.

 

IF(CONTAINSSTRING(Table[CompanyNumber],"Company2"),IF(Table[Letter Received]="No" && ISBLANK(Table[Responded],
IF(Table[CompanyNumber]<>"Company2"),IF(Table[Letter Received]<>"No" && ISBLANK(Table[Responded]),
"Check",
"Pass"
)

2 REPLIES 2
techies
Solution Sage
Solution Sage

Hi @JK-1 if you prefer to use nested if, please try this calculated column

 

Result =
IF (
Table[CompanyNumber] = "Company2",
IF (
Table[Letter Received] = "No" && ISBLANK(Table[Responded]),
"Check",
"Pass"
),
IF (
Table[Letter Received] <> "No" && ISBLANK(Table[Responded]),
"Check",
"Pass"
)
)

DataNinja777
Super User
Super User

Hi @JK-1 ,

 

The best and most recommended way to write this logic in DAX is by using the SWITCH function.

This approach is cleaner, easier to read, and more scalable than nested IF statements, making it a best practice for handling multiple conditions. It evaluates each condition in order and returns the result for the first one that is true.

YourNewColumn =
SWITCH(
    TRUE(),
    CONTAINSSTRING(Table[CompanyNumber], "Company2") && Table[Letter Received] = "No" && ISBLANK(Table[Responded]), "Check",
    Table[CompanyNumber] <> "Company2" && Table[Letter Received] <> "No" && ISBLANK(Table[Responded]), "Check",
    "Pass" // This is the default result if no other condition is met
)

 

Best regards,

Helpful resources

Announcements
May PBI 25 Carousel

Power BI Monthly Update - May 2025

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

May 2025 Monthly Update

Fabric Community Update - May 2025

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