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
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,
- JK-11 year ago
Helper II
Thank you all for these suggestions. If I just ignored CompanyNumber for now, and although wouldn't expect the Letter Received or Responded data to be blank would I have to list the variables below for a Check result achieved where either: Letter Received or Responded blank, or both blank.
I've tested them as new - and think all are necessary, did some adaptations (separately) - so has been very useful in understanding the construction but wanted to make sure I wasn't adding in something extra in this slight follow on.
reassessed = SWITCH(TRUE(),ISBLANK([Letter Received]) && NOT ISBLANK([Responded]),"Check",NOT ISBLANK([Letter Received]) && ISBLANK([Responded]),"Check",ISBLANK([Letter Received]) && ISBLANK([Responded]),"Check","Pass")