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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Anonymous
Not applicable

SWITCH function failing wiht measures

Hello community, I hope you can help me with this.

 

I am working with a SQL Database into my Power BI desktop, in which I have 'Deal ID' and 'Amount', and I am trying to create a custom column to categorize those deals by 'Deal Band'.

 

After trying many times with nested IF and SWITCH, I can't still find the right way to make it work. Also,  Conditional Column is not letting me the 'between' option for measures, and it doesn't work either.

 

Here is the code that I am using:

 

[Deal Band]:=

SWITCH(
       TRUE(),
  [Amount]<=5000,”<5K″,
  [Amount]<=10000,”5-10K″,
  [Amount]<=20000,”10-20K”,

  [Amount]<=50000,”20-50K″

  [Amount]<=100000,”50-100K″,

  [Amount]<=500000,”100-500K″,

  [Amount]<=1000000,”500K-1M″,

  “1M+”)

 

Can somebody help me understand what am I doing wrong?

 

Also, would it be possible to have an improved version of nested IF predefined with ranges for values?

 

Thank you very much in advance.

 

Pablo

1 ACCEPTED SOLUTION

Banding is done in columns, not measures. Read my 2 articles here

https://exceleratorbi.com.au/banding-in-dax/

https://exceleratorbi.com.au/conditional-columns-power-bi-desktop/



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

View solution in original post

5 REPLIES 5
Danke1981
New Member

Another solution would be:

Grouping the amount first

                                                                  Group

[Amount]<=5000,                                       "1"
5000<[Amount]<=10000,                           "2"
10000<[Amount]<=20000,                         "3"

20000<[Amount]<=50000,                         "4"

.

.

.

Then use swith function:

WITCH(
       TRUE(),
  [Group]=1 ,”<5K″,
  [Group]=2 ,”5-10K″,

.

.

.

.

Ashish_Mathur
Super User
Super User

Hi,

 

What problem are you facing?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi,

 

i am also facing same problem. when i am trying write the column name after TRUE() function, it is not showing me any table/column name. please help

 

 

Anonymous
Not applicable

Hello @Ashish_Mathur

After trying both 'import' and 'direct query', I have the same error when I apply the formula: 

The following syntax error occurred during parsing: Invalid token, Line 1, Offset 32, ”

 

This is the exact formula that I use:

 

Measure = SWITCH(TRUE(),
vw_PRMCancelled[Amount]<=5000,”<5K″,
vw_PRMCancelled[Amount]<=10000,”5-10K″,
vw_PRMCancelled[Amount]<=20000,”10-20K”,
vw_PRMCancelled[Amount]<=50000,”20-50K″,
vw_PRMCancelled[Amount]<=100000,”50-100K″,
vw_PRMCancelled[Amount]<=500000,”100-500K″,
vw_PRMCancelled[Amount]<=1000000,”500K-1M″,
“1M+”)

 

Any help will be appreciated.

 

Thanks

Banding is done in columns, not measures. Read my 2 articles here

https://exceleratorbi.com.au/banding-in-dax/

https://exceleratorbi.com.au/conditional-columns-power-bi-desktop/



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.

Top Solution Authors
Top Kudoed Authors