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
IcingOnTheCake
Helper III
Helper III

Add category column with top10%, high20%... information in certain context

Dear Experts,

thanks for reading.

I have a table with some informational columns and a price column.

I would like to add one more column (category) with the information to what range (top 10%, high 20%, medium 30%, low40%) this priceamount belongs to based on a certain context. (By subsidiary etc.. context will be selected in slicers)

 

This result, the category column, should be available in a slicer.

 

For example:

Slicer with: top/high/medium/low

 

Company   Name               Quoteno    Price    Category

Sweden      Customer1       12566         100        low

Sweden      Customer2       12567         4000      high

Belgium      Customer6       1z665         100        low

...

Thank you for your help

1 ACCEPTED SOLUTION
v-deddai1-msft
Community Support
Community Support

Hi @IcingOnTheCake ,

 

You could create the following two calculated column:

 

RANK = RANKX('Table','Table'[Price],,ASC,Dense) 

Category = var a = 'Table'[RANK]/MAX('Table'[RANK]) return SWITCH(TRUE(),a<=0.1,"top",a>0.1&&a<=0.3,"high",a>0.3&&a<=0.6,"medium",a>0.6&&a<=1,"low")

 

Capture3.PNG

 

If this post help, please consider accept it as the solution to help others find it more  quickly.

 

Best Regard,

Dedmon Dai

View solution in original post

4 REPLIES 4
v-deddai1-msft
Community Support
Community Support

Hi @IcingOnTheCake ,

 

You could create the following two calculated column:

 

RANK = RANKX('Table','Table'[Price],,ASC,Dense) 

Category = var a = 'Table'[RANK]/MAX('Table'[RANK]) return SWITCH(TRUE(),a<=0.1,"top",a>0.1&&a<=0.3,"high",a>0.3&&a<=0.6,"medium",a>0.6&&a<=1,"low")

 

Capture3.PNG

 

If this post help, please consider accept it as the solution to help others find it more  quickly.

 

Best Regard,

Dedmon Dai

vanessafvg
Super User
Super User

you can create a column with a switch statement

 

ie

 

SWITCH(
       TRUE(),
      [price]>100,"high″,
      [price]<100,"low″
            )

 

                            





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




thank you @vanessafvg ! But the "100" needs to be variable. I dont know the ranges. it's by formula.

the price/row belongs to the top category, if the price is one of the top10% prices (in the table)

the price/row belongs to the high category, if the price is one of the prices that is in the range from top 11 to 30%

the price/row belongs to the medium category, if the price is one of the prices that is in the range from top 31% to 60% 

and 

the price/row belongs to the low category, if the price is one of the prices that is in the range from 61% to 100% 

 

sorry for the explanation. But it's hard to explain...

Thank you

hi @IcingOnTheCake 

 

you will need to create a ranking first 

https://www.youtube.com/watch?v=z2qzJVeYhTY&t=195s

 

then use that ranking to assign the value.   

 

 





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




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.