Forum Discussion

tk0501's avatar
tk0501
Frequent Visitor
7 years ago
Solved

How do I get average values between prescribed percentiles from an unsorted list?

Hello, I have a measure that returns 10,000 un-sorted values for each of the 10 years.  Row - 10,000 samples  Col - 10 Years Value - unsorted numbers   How do I display average values between 4...
  • v-juanli-msft's avatar
    v-juanli-msft
    7 years ago

    Hi tk0501 

    I use "RAND" function to create a value column which its value will change every time.

    So maybe when you look into my pbix, the data is not like the visuals below.

    It's just for test.

     

    In my table, i create measures/columns according to your step:


    tk0501 wrote:
    1. I'm defining Percentile by ranking [Sum of all values for each year per sample] 
      • For each Sample - add all the values  (measure [Sum/sample])
      • Rank the samples in order of largest to smallest  (measure [rank sample])
      • if you had 100 samples, the top 10 samples would make up [0-10th percentile] (column [percentile row])
    2. Using the above example, for [0-10th percentile] row
      • I want to average of 10 samples worth of values for each year (measure [average])

    measure:
    Sum/sample = CALCULATE(SUM('Table'[value]),ALLEXCEPT('Table','Table'[sample]) )
    
    rank sample = RANKX(ALL('Table'),[Sum/sample],,DESC,Dense)
    
    column:
    percentile row =
    SWITCH (
        TRUE (),
        [rank sample] <= 10, "0-10th percentile",
        [rank sample] <= 20, "11-20th percentile",
        [rank sample] <= 40, "21-40th percentile"
    )
    
    measure:
    average = CALCULATE(AVERAGE('Table'[value]),ALLEXCEPT('Table','Table'[year],'Table'[percentile row]))

    Best Regards
    Maggie

     

    Community Support Team _ Maggie Li
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.