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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
EMassicot
Frequent Visitor

DAX FUNCTION FOR TIERS?

 I want to create a table with three columns: Sales Rep, Dollar Amount and Tier. Right now all I have is the Sales Rep and Dollar amount columns. I want to dynamically group Sales Rep with  Dollar Amount so that each row is based on 5 tiers.  In other words the 1st 20% of Sales Reps with the most dollar amount value receive a tier 1....the next 20% a tier 2...etc...

 

Is there anyway to do this?

 

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @EMassicot ,

 

Taking into account that you have only those two columns you can do it in the following way:

  • Create a new column with the following syntax:

 

Tiers =
VAR rankingValue =
    DIVIDE ( RANKX ( 'Table', 'Table'[Sales] ), COUNTROWS ( 'Table' ) )
RETURN
    SWITCH (
        TRUE (),
        rankingValue < 0.20, 1,
        rankingValue >= 0.20
            && rankingValue < 0.4, 2,
        rankingValue >= 0.40
            && rankingValue < 0.6, 3,
        rankingValue >= 0.60
            && rankingValue < 0.8, 4,
        rankingValue >= .80
            && rankingValue <= 1, 5
    )

 

MFelix_0-1657053383197.png

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

Do you want a measure or a calculated column formula?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-yangliu-msft
Community Support
Community Support

Hi  @EMassicot ,

 

Has your problem been solved? If it is solved, you can mark the correct answer. If it is not solved, you can provide more detailed information and we can help you better. 

 

Best Regards,

Liu Yang

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

MFelix
Super User
Super User

Hi @EMassicot ,

 

Taking into account that you have only those two columns you can do it in the following way:

  • Create a new column with the following syntax:

 

Tiers =
VAR rankingValue =
    DIVIDE ( RANKX ( 'Table', 'Table'[Sales] ), COUNTROWS ( 'Table' ) )
RETURN
    SWITCH (
        TRUE (),
        rankingValue < 0.20, 1,
        rankingValue >= 0.20
            && rankingValue < 0.4, 2,
        rankingValue >= 0.40
            && rankingValue < 0.6, 3,
        rankingValue >= 0.60
            && rankingValue < 0.8, 4,
        rankingValue >= .80
            && rankingValue <= 1, 5
    )

 

MFelix_0-1657053383197.png

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors