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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

DAX SWITCH FORMULA SHOWING INCORRECT GROUPING

Hi,

 

I'm trying to create a DAX formula using switch. I need to group all negative numbers to display no_new_return|prev rtn. However, some negative numbers are falling into other groups designated for positive values. Example -41 is falling in other groups such as 0-21,22-30 etc. as highlighted in the below image. The formula works for numbers > 0 but the negatives are not being recognized. Any assistance is appreciated. 

 

formula : 

ORD_RCPT_TENURE_GROUP = SWITCH(TRUE(),'FF_ORDER_MST'[ORD_RCPT_TENURE]<0,"NO_NEW_RTN | PREV RTN",'FF_ORDER_MST'[ORD_RCPT_TENURE]>=0 && 'FF_ORDER_MST'[ORD_RCPT_TENURE]<=21,"0-21",'FF_ORDER_MST'[ORD_RCPT_TENURE]>21 && 'FF_ORDER_MST'[ORD_RCPT_TENURE]<=30,"22-30",'FF_ORDER_MST'[ORD_RCPT_TENURE]>30 && 'FF_ORDER_MST'[ORD_RCPT_TENURE]<=60,"31-60",'FF_ORDER_MST'[ORD_RCPT_TENURE]>60 && 'FF_ORDER_MST'[ORD_RCPT_TENURE]<=90,"61-90",'FF_ORDER_MST'[ORD_RCPT_TENURE]>90 && 'FF_ORDER_MST'[ORD_RCPT_TENURE]<=120,"91-120",'FF_ORDER_MST'[ORD_RCPT_TENURE]>120 && 'FF_ORDER_MST'[ORD_RCPT_TENURE]<=180,"121-180",'FF_ORDER_MST'[ORD_RCPT_TENURE]>180 && 'FF_ORDER_MST'[ORD_RCPT_TENURE]<=365,"181-365",'FF_ORDER_MST'[ORD_RCPT_TENURE]>365,"+365","NO_NEW_RTN | PREV RTN")the value -41 is showing in 3 different groups.the value -41 is showing in 3 different groups.
1 ACCEPTED SOLUTION
v-jianboli-msft
Community Support
Community Support

Hi @Anonymous ,

 

Your MEASURE [ORD_RCPT_TENURE] seems to involve two tables? This seems to be the source of the problem. What exactly do these two tables look like? What is the relationship between them?

Sorry for that the information you have provided is not making the problem clear to me. Can you please share more details to help us clarify your scenario?

Please provide me with more details about your table and your problem or share me with your pbix file after removing sensitive data.

 

Refer to:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

 

Best Regards,

Jianbo Li

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
v-jianboli-msft
Community Support
Community Support

Hi @Anonymous ,

 

Your MEASURE [ORD_RCPT_TENURE] seems to involve two tables? This seems to be the source of the problem. What exactly do these two tables look like? What is the relationship between them?

Sorry for that the information you have provided is not making the problem clear to me. Can you please share more details to help us clarify your scenario?

Please provide me with more details about your table and your problem or share me with your pbix file after removing sensitive data.

 

Refer to:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

 

Best Regards,

Jianbo Li

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

Anonymous
Not applicable

It was the relationship between the two tables. Thank you!

Anonymous
Not applicable

Hello,

 

measure: 

ORD_RCPT_TENURE = DATEDIFF(MAXX(FF_ORDER_MST,'FF_ORDER_MST'[CPE_ORDER_DUE_DT]),MAXX(Recpt_Combined,'Recpt_Combined'[RECPT_DATE]),
DAY)
 
calculated column : 
ORD_RCPT_TENURE_GROUP = SWITCH(TRUE(),'FF_ORDER_MST'[ORD_RCPT_TENURE]<0,"NO_NEW_RTN | PREV RTN",'FF_ORDER_MST'[ORD_RCPT_TENURE]>=0 && 'FF_ORDER_MST'[ORD_RCPT_TENURE]<=21,"0-21",'FF_ORDER_MST'[ORD_RCPT_TENURE]>21 && 'FF_ORDER_MST'[ORD_RCPT_TENURE]<=30,"22-30",'FF_ORDER_MST'[ORD_RCPT_TENURE]>30 && 'FF_ORDER_MST'[ORD_RCPT_TENURE]<=60,"31-60",'FF_ORDER_MST'[ORD_RCPT_TENURE]>60 && 'FF_ORDER_MST'[ORD_RCPT_TENURE]<=90,"61-90",'FF_ORDER_MST'[ORD_RCPT_TENURE]>90 && 'FF_ORDER_MST'[ORD_RCPT_TENURE]<=120,"91-120",'FF_ORDER_MST'[ORD_RCPT_TENURE]>120 && 'FF_ORDER_MST'[ORD_RCPT_TENURE]<=180,"121-180",'FF_ORDER_MST'[ORD_RCPT_TENURE]>180 && 'FF_ORDER_MST'[ORD_RCPT_TENURE]<=365,"181-365",'FF_ORDER_MST'[ORD_RCPT_TENURE]>365,"+365","NO_NEW_RTN | PREV RTN")
FreemanZ
Super User
Super User

hi @Anonymous 

what column/measure do you have for the table visual?

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.