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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

SWITCH not supporting comparsion of True/False and Integer

Hi guys,
 
i need to use the SWITCH function to increase month numbers by 1. I have to use SWITCH and can't go to IF due to specific reasons that would take too long to explain. Therefore i need to make this formular work:
 
SWITCH(
MONTH([First_Sale_Date_SKU])=11;12;
MONTH([First_Sale_Date_SKU])=12;1;
MONTH('DB2 (2)'[First_Sale_Date_SKU]))
 
The problem now with SWITCH is that PBI says SWITCH does not support comparison between type True/False and Integer. And that i should use Format or Value function. 
 
Can someone explain what exactly that means and how to fix this? 
 
Thank you guys!
2 ACCEPTED SOLUTIONS
ibarrau
Super User
Super User

Hi! there is a problem in the syntax. Check the doc: https://docs.microsoft.com/en-us/dax/switch-function-dax

 

It should be like this:

SWITCH( MONTH([First_Sale_Date_SKU]) ;
    11;12;
    12;1;
    MONTH('DB2 (2)'[First_Sale_Date_SKU])
)

 First is the expression. You don't have to add the "=" there, it will asume it.

 

Regards,


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Happy to help!

LaDataWeb Blog

View solution in original post

dax
Community Support
Community Support

Hi @Anonymous , 

You need to use below expression to see whteher it work or not

 

Column = SWITCH(TRUE(),MONTH('Table (2)'[date])=11,12 ,MONTH('Table (2)'[date])=12,1)

 

or 

 

Column = SWITCH(MONTH('Table (2)'[date]),11,12 ,12,1)

 

In your expression, you didn't write the correct condition, so it can't compare the value(MONTH('DB2 (2)'[First_Sale_Date_SKU]), you didn't give the comparison value).

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
dax
Community Support
Community Support

Hi @Anonymous , 

You need to use below expression to see whteher it work or not

 

Column = SWITCH(TRUE(),MONTH('Table (2)'[date])=11,12 ,MONTH('Table (2)'[date])=12,1)

 

or 

 

Column = SWITCH(MONTH('Table (2)'[date]),11,12 ,12,1)

 

In your expression, you didn't write the correct condition, so it can't compare the value(MONTH('DB2 (2)'[First_Sale_Date_SKU]), you didn't give the comparison value).

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

ibarrau
Super User
Super User

Hi! there is a problem in the syntax. Check the doc: https://docs.microsoft.com/en-us/dax/switch-function-dax

 

It should be like this:

SWITCH( MONTH([First_Sale_Date_SKU]) ;
    11;12;
    12;1;
    MONTH('DB2 (2)'[First_Sale_Date_SKU])
)

 First is the expression. You don't have to add the "=" there, it will asume it.

 

Regards,


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Happy to help!

LaDataWeb Blog

amitchandak
Super User
Super User

what is data type of First_Sale_Date_SKU

Anonymous
Not applicable

It's a Date type column

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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