Forum Discussion

aar0n's avatar
aar0n
Advocate II
8 years ago
Solved

Help with a Top value

Hi Guys, 

 

I am trying to create a "Hall of Fame" tab in my report. 

 

pretty much, i want the user to select one of many measures that describe my data, and then be able to select top 10% of values, top 25% of values, and top 50% of values.

 

a sample of my data is below:

NameDateValue
a1/1/201791
a1/2/201723
a1/3/201764
a1/4/201774
a1/5/201747
a1/6/201786
b1/1/201769
b1/2/201792
b1/3/201774
b1/4/201766
b1/5/201728
b1/6/201738
c1/1/201735
c1/2/201748
c1/3/201792
c1/4/201768
c1/5/201781
c1/6/201730


i am looking to make some measures/filters that would select:

top 10% of "names" with:
the highest max value, 
the highest cumulative value
the highest average value for the first 3 months.  

 

then the selection would plot the names on a graph. the above data is a quick representation of my data (where my data set has ~8Million rows)

  • Hi aar0n,

     

    Create a new table Options like below:

     

    Then create a measure in the table using DAX:

    Result =
    SWITCH (
        TRUE (),
        SELECTEDVALUE ( Options[Options] ) = "Top 10% Names By Average", [Top 10% Names By Average],
        SELECTEDVALUE ( Options[Options] ) = "Top 10% Names By Total", [Top 10% Names By Total],
        SELECTEDVALUE ( Options[Options] ) = "Top 10% Names By Max", [Top 10% Names By Max]
    )
    

     

     

    Regards,

    Jimmy Tao

4 Replies

  • v-yuta-msft's avatar
    v-yuta-msft
    Community Support

    Hi aar0n,

     

    To achieve your requirement, you should create rankings by max value, total value and average value. Create three calculate columns using DAX below:

    Rank By Max = RANKX(ALL(Table1), CALCULATE(MAX(Table1[Value]), ALLEXCEPT(Table1, Table1[Name])),,DESC,Dense)
    
    Rank By Total = RANKX(ALL(Table1), CALCULATE(SUM(Table1[Value]), ALLEXCEPT(Table1, Table1[Name])),,DESC,Dense)
    
    Rank By Average = RANKX(ALL(Table1), CALCULATE(AVERAGE(Table1[Value]), ALLEXCEPT(Table1, Table1[Name])),,DESC,Dense)

    Then to achieve the names which achieve the top 10% rankings above, create three measures using DAX below:

    Top 10% Names By Max = 
    VAR divide_ = ROUNDUP(MAX(Table1[Rank By Max]) * 0.1, 0)
    VAR name_ = CALCULATETABLE(VALUES(Table1[Name]), FILTER(ALL(Table1), Table1[Rank By Max] <=  divide_))
    RETURN
    CONCATENATEX(name_, Table1[Name], ",")
    
    Top 10% Names By Total = 
    VAR divide_ = ROUNDUP(MAX(Table1[Rank By Total]) * 0.1, 0)
    VAR name_ = CALCULATETABLE(VALUES(Table1[Name]), FILTER(ALL(Table1), Table1[Rank By Total] <=  divide_))
    RETURN
    CONCATENATEX(name_, Table1[Name], ",")
    
    Top 10% Names By Average = 
    VAR divide_ = ROUNDUP(MAX(Table1[Rank By Average]) * 0.1, 0)
    VAR name_ = CALCULATETABLE(VALUES(Table1[Name]), FILTER(ALL(Table1), Table1[Rank By Average] <=  divide_))
    RETURN
    CONCATENATEX(name_, Table1[Name], ",")

    The result is like this:

     

     

    Hope it's helpful to you.

     

    Jimmy Tao

    • aar0n's avatar
      aar0n
      Advocate II

      hi v-yuta-msft

      thank you for your quick response. this reply is very helpful, but there are some changes i was hoping for, 

       

      for example, 

      instead of just displaying the measure in a data card, would it be possible to use the measure (or a different method) in some type of filter?

      what i was hoping for was the ability to click "top 10% names by max" and then my other visuals in my report would filter to those names.

       

       

      The reason i need this, is that Power bi only graphs a subset of my data (and i can't truly see the top percentile of data)

      • v-yuta-msft's avatar
        v-yuta-msft
        Community Support

        Hi aar0n,

         

        Create a new table Options like below:

         

        Then create a measure in the table using DAX:

        Result =
        SWITCH (
            TRUE (),
            SELECTEDVALUE ( Options[Options] ) = "Top 10% Names By Average", [Top 10% Names By Average],
            SELECTEDVALUE ( Options[Options] ) = "Top 10% Names By Total", [Top 10% Names By Total],
            SELECTEDVALUE ( Options[Options] ) = "Top 10% Names By Max", [Top 10% Names By Max]
        )
        

         

         

        Regards,

        Jimmy Tao