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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
cathoms
Responsive Resident
Responsive Resident

Using "and" in a conditional column

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"

 

 

cathoms_0-1614116076452.png

 

Thanks in advance!

1 ACCEPTED SOLUTION
CNENFRNL
Community Champion
Community Champion

@cathoms 

= 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!

View solution in original post

2 REPLIES 2
CNENFRNL
Community Champion
Community Champion

@cathoms 

= 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!

HotChilli
Super User
Super User

It needs an "else " case at the end

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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