Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Quartiles and average per quartile

Hi,

 

I need some help with creating rank and quartiles based on the result of a measure. I then need to be able to list the average result for each quartile.

 

I have included a (very oversimplified) sample file https://1drv.ms/u/s!AnRGj-TQo1jAg-MNMTUq62UGVjTcSw?e=df6yJa 

 

The output I need is twofold:

1. The Quartile of Conversion by employee:

 

Employee NameConversion (Measure)RankQuartile
Employee 1992.0%11
Employee 1784.7%21
Employee 0279.7%31
Employee 1479.2%41
Employee 0578.0%51
Employee 1877.8%62
Employee 0877.4%72
Employee 1576.2%82
Employee 1174.9%92
Employee 1074.7%102
Employee 0473.1%113
Employee 0672.5%123
Employee 1269.7%133
Employee 1368.2%143
Employee 0167.9%153
Employee 0366.4%164
Employee 2064.3%174
Employee 0962.2%184
Employee 1660.2%194
Employee 0756.1%204

 

and then the average conversion for each quartile:

 

QuartileAverage Conversion
182.7%
276.2%
370.3%
461.8%

 

I am going round in circles, I can't quite get quartiles to display correctly using PERCENTILE.INC() and I don't know where to start with the average conversion per quartile!


Any help would be greatly appreciated. It's driving me nuts!

5 Replies

  • Anonymous I never did this before but I gave it a shot, solution is attached, you can tweak it as you see fit.

     

     

    Follow us on LinkedIn

     

    Check my latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

     

    Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.

     

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      parry2k Thank you so much, I think you cracked it for me. I will have a go at translating this into my more complicated model, wish me luck and thanks again!

    • Sirhawk3017's avatar
      Sirhawk3017
      Helper II

      It's been a bit of time since this last post, but what if you wanted to turn this into a bar chart. Similar to the below. Is this even possible? 

       

       

       

       

  • Anonymous's avatar
    Anonymous
    Not applicable

    parry2k I think I have a problem that I don't know how to resolve. My actual data is much more complicated and cannot be shared. I'm having to use ALLSELECTED, as I have a filterable list of employees, not just ALL. In the Rank, this works perfectly. 
    For some reason, using that same ALLSELECTED to replace ALL within PERCENTILEX.INC, using your DAX means that all the 0.25, 0.5 amd 0.75 comes out to the same value - the highest value of Rank and therefore the Quartile result is 1 for everyone.

    My suspision is that ALLSELECTED is changing the context to the row, when it's used in a VAR in this way, and I cannot figure out how to change that. Any ideas?

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      I actually think I cracked this myself. I have 2 columns in my employee table:

       

      Employee NameEmployee Number
      John Smith001
      Jane Doe002
      Joe Bloggs003
      John Smith004

       

       

      Originally I had a problem where I had multiple employees with the same names, so had added 2 calculated columns, 1 to count the instances of that employee name and the other to concatenate the name and employee number if there were more than 2 people with the same name, I figured a calculated column would be fine for only a few hundred rows of data:

       

        Calculated ColumnCalculated Column
      Employee NameEmployee NumberName CountNew Employee Name
      John Smith0012John Smith (001)
      Jane Doe0021Jane Doe
      Joe Bloggs0031Joe Bloggs
      John Smith0042John Smith (004)

       

      Basing my PERCENTILEX.INC using HASONEVALUE on the New Employee Name Calculated column just would not work - as soon as I moved the Name Count / New Employee Name logic into Power Query, it worked a treat!