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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Anonymous
Not applicable

Switch statement issue

Hello Community:   I am trying to understand why the negative percent (discount) values are creeping into my table below.    I have this measure used in the chart below, and when I select the 20% or Less column, it is working correctly, however there are some negative percentages that show up in the table which is dynamically being filtered from the column chart.   

 

Is there something wrong with my SWITCH statement?

 

 

Discount Cohorts = SWITCH
(TRUE(),
'AllOpps-Products'[Discount]>=0.0 && 'AllOpps-Products'[Discount]<=.10,"10% or less",
'AllOpps-Products'[Discount]<=0.20,"20% or less",
'AllOpps-Products'[Discount]<=0.30,"30% or less",
'AllOpps-Products'[Discount]<=0.40,"40% or less",
'AllOpps-Products'[Discount]<=.50,"50% or less",
BLANK()
)

 

texmexdragon_0-1618765511048.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@HotChilli  That was a good tip and got me in the right direction.  Added a few more statements and perfecto.   This was the final measure that allowed for the correct grouping whether in a column chart or table. 

 

Discount Cohorts = IF(ISBLANK('AllOpps-Products'[Discount]),"Blank",
SWITCH
(TRUE(),
'AllOpps-Products'[Discount]< 0,"Negative %",
'AllOpps-Products'[Discount]>= 0.0000 && 'AllOpps-Products'[Discount]<.11,"0 to 10%",
'AllOpps-Products'[Discount]>= 0.11 && 'AllOpps-Products'[Discount]<.21,"11 to 20%",
'AllOpps-Products'[Discount]>= 0.21 && 'AllOpps-Products'[Discount]<0.31,"21 to 30%",
'AllOpps-Products'[Discount]>= 0.31 && 'AllOpps-Products'[Discount]<0.41,"31 to 40%",
'AllOpps-Products'[Discount]>= 0.41 && 'AllOpps-Products'[Discount]<.51,"41 to 50%",
'AllOpps-Products'[Discount]>= 0.51 && 'AllOpps-Products'[Discount]<=1.0,"51 to 100% ",
"Other"
))

View solution in original post

2 REPLIES 2
HotChilli
Community Champion
Community Champion

Investigate which cohort negative discounts get assigned to.  

The easiest way is to add a table visual with discount and discount cohort. (as long as they don't aggregate).

Which cohort do you expect?

 

Anonymous
Not applicable

@HotChilli  That was a good tip and got me in the right direction.  Added a few more statements and perfecto.   This was the final measure that allowed for the correct grouping whether in a column chart or table. 

 

Discount Cohorts = IF(ISBLANK('AllOpps-Products'[Discount]),"Blank",
SWITCH
(TRUE(),
'AllOpps-Products'[Discount]< 0,"Negative %",
'AllOpps-Products'[Discount]>= 0.0000 && 'AllOpps-Products'[Discount]<.11,"0 to 10%",
'AllOpps-Products'[Discount]>= 0.11 && 'AllOpps-Products'[Discount]<.21,"11 to 20%",
'AllOpps-Products'[Discount]>= 0.21 && 'AllOpps-Products'[Discount]<0.31,"21 to 30%",
'AllOpps-Products'[Discount]>= 0.31 && 'AllOpps-Products'[Discount]<0.41,"31 to 40%",
'AllOpps-Products'[Discount]>= 0.41 && 'AllOpps-Products'[Discount]<.51,"41 to 50%",
'AllOpps-Products'[Discount]>= 0.51 && 'AllOpps-Products'[Discount]<=1.0,"51 to 100% ",
"Other"
))

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.