Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hello
I hope a kind soul may be able to help me out. I am trying to convert the attached Cognos case statement into a DAX statement, in a caclulated column. I have been trying for a whole using a mix of if(and and if(isblank and so on but simply cannot get my head around it and hence can't get it written to produce the correct result.
Any DAX heroes suggest a statement that might work pretty please?
Solved! Go to Solution.
Something like this?
Switch ( true ( )
, [field1] = blank() && [field2] = blank() , "double oops"
, [field1] = blank() , "type-1 oops"
, [field2] = blank(), "type-2 oops"
, "Undefined"
)
Or if you want to stay with if please see below. I didn't do exactly the same to yours but used all logical tests you need. Just replace it with your values.
Play with it as it works, just tested it.
Hi @Anonymous ,
Try using a SWITCH() Switch is a link to explanation, and there are a lot of videos out there as well.
SWITCH([Month],
1,"January",
2,"February",
"Some other month"
)
Takes a group of nested ifs and turns it into a readable function. The function stops at the first one that is true. I always think of it as a penny dropped into a pond, and if there is nothing to stop it (nothing true) then you get the value at the bottom.
Let me know if you have any questions.
If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel
Proud to be a Super User!
@Nathaniel_C wrote:Hi @Anonymous ,
Try using a SWITCH() Switch is a link to explanation, and there are a lot of videos out there as well.
SWITCH([Month],
1,"January",
2,"February",
"Some other month"
)Takes a group of nested ifs and turns it into a readable function. The function stops at the first one that is true. I always think of it as a penny dropped into a pond, and if there is nothing to stop it (nothing true) then you get the value at the bottom.
Let me know if you have any questions.
If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel
Hey Nathaniel
Thanks for your reply - I've been having a play with 'Switch' since you kindly replied but am still struggling. I think it is the mixture of the AND conditions mixed with me trying to compare where there are potentially blank values that are throwing me. Also as I am calling different fields in the expression - do I need to nest the switch? I'm very confused 😞
Something like this?
Switch ( true ( )
, [field1] = blank() && [field2] = blank() , "double oops"
, [field1] = blank() , "type-1 oops"
, [field2] = blank(), "type-2 oops"
, "Undefined"
)
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
143 | |
84 | |
64 | |
52 | |
49 |
User | Count |
---|---|
211 | |
87 | |
80 | |
69 | |
60 |