The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I'm making a conditional column and instead of using the "Conditional Column" tool I thought I would try coding it in a custom colum. Is it possible to use "if-and" statements? My code throws up an error: Token Literal expected. Why am I getting this error and can I fix it?
= if [#"Days btw CNCL & APPT"] >= 92 then "More than 3 months"
else if [#"Days btw CNCL & APPT"] >= 61 and < 92 then "2-3 months"
else if [#"Days btw CNCL & APPT"] > 30 and < 61 then "1-2 months"
else if [#"Days btw CNCL & APPT"] > 14 and < 30 then "3-4 weeks"
else if [#"Days btw CNCL & APPT"] > 7 and < 14 then "1-2 weeks"
else if [#"Days btw CNCL & APPT"] > 2 and < 7 then "Within 1 week"
else if [#"Days btw CNCL & APPT"] <= 2 then "Within 48 hrs"
else if [#"Days btw CNCL & APPT"] <= 1 then "Within 24 hrs"
Thanks in advance!
Solved! Go to Solution.
= if [#"Days btw CNCL & APPT"] >= 92 then "More than 3 months"
else if [#"Days btw CNCL & APPT"] >= 61 then "2-3 months"
else if [#"Days btw CNCL & APPT"] > 30 then "1-2 months"
else if [#"Days btw CNCL & APPT"] > 14 then "3-4 weeks"
else if [#"Days btw CNCL & APPT"] > 7 then "1-2 weeks"
else if [#"Days btw CNCL & APPT"] > 2 then "Within 1 week"
else if [#"Days btw CNCL & APPT"] > 1 then "Within 48 hrs"
else "Within 24 hrs"
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
= if [#"Days btw CNCL & APPT"] >= 92 then "More than 3 months"
else if [#"Days btw CNCL & APPT"] >= 61 then "2-3 months"
else if [#"Days btw CNCL & APPT"] > 30 then "1-2 months"
else if [#"Days btw CNCL & APPT"] > 14 then "3-4 weeks"
else if [#"Days btw CNCL & APPT"] > 7 then "1-2 weeks"
else if [#"Days btw CNCL & APPT"] > 2 then "Within 1 week"
else if [#"Days btw CNCL & APPT"] > 1 then "Within 48 hrs"
else "Within 24 hrs"
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
It needs an "else " case at the end