Forum Discussion
IF statement and conditions
- Anonymous1 year ago
Hi JK-1,
Thank you for reaching out to the Microsoft Fabric Forum Community. And also thanks to Nasif_Azam , techies and DataNinja777 for Prompt and helpful response.
Just following up to see if the solution provided was helpful in resolving your issue. Please feel free to let us know if you need any further assistance.
If the response addressed your query, kindly mark it as Accepted Solution and click Yes if you found it helpful this will benefit others in the community as well.
Best regards,
Prasanna Kumar
Hey JK-1 ,
You're on the right track, and yes you can handle this logic using SWITCH, IF, or a combination of both, but in your case with only two conditions and some AND/ISBLANK logic, a nested IF structure is easier and more appropriate than SWITCH.
Let's first clarify your intent in plain logic:
If CompanyNumber = "Company2" AND Letter Received = "No" AND Responded is blank → "Check"
If CompanyNumber ≠ "Company2" AND Letter Received ≠ "No" AND Responded is blank → "Check"
Else → "Pass"
Corrected and Optimized DAX
Result =
IF (
(Table[CompanyNumber] = "Company2" && Table[Letter Received] = "No" && ISBLANK(Table[Responded])) ||
(Table[CompanyNumber] <> "Company2" && Table[Letter Received] <> "No" && ISBLANK(Table[Responded])),
"Check",
"Pass"
)Explanation
I combined your two conditions using an OR (||) operator at the outer level.
Each condition group is clearly separated using parentheses.
This avoids deeply nested IFs and improves readability.
Why Not SWITCH?
SWITCH works best when you're checking a single column against many constant values. Since you're testing multiple columns and a combination of boolean expressions, SWITCH would require complex nesting and doesn't simplify the logic here.
If you expect to scale this logic with more conditions, you could modularize the logic into variables using a calculated column:
Result =
VAR IsCompany2Check = Table[CompanyNumber] = "Company2" && Table[Letter Received] = "No" && ISBLANK(Table[Responded])
VAR IsOtherCheck = Table[CompanyNumber] <> "Company2" && Table[Letter Received] <> "No" && ISBLANK(Table[Responded])
RETURN
IF (IsCompany2Check || IsOtherCheck, "Check", "Pass")
If you found this solution helpful, please consider accepting it and giving it a kudos (Like) it’s greatly appreciated and helps others find the solution more easily.
Best Regards,
Nasif Azam