Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

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 Am...
  • MFelix's avatar
    4 years ago

    Hi Anonymous ,

     

    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
        )