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
cshynne
Regular Visitor

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 @cshynne ,

 

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 @cshynne ,

 

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.

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

cshynne
Regular Visitor

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 @cshynne 

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

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.

Top Solution Authors