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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
DHB
Helper V
Helper V

Calculate Percentiles Using Two Variables

I have created a percentile measure in my data using one column of data (ENGAGED_DAYS) but where more than one person has the same value (i.e. PERSON_CODE 2 and 3) I'd like to use another column as a tie-breaker (REQUEST_PER_ACTIVE_DAY). 

 

The data looks like this...

COURSE_CODEPERSON_CODEENGAGED_DAYSREQUESTS_PER_ACTIVE_DAY
MATHS10111015
MATHS10121511
MATHS10131517
MATHS10142010

 

I created this measure...

EngDays = SUM('All Faculty Course Activity Percentile 2022-04-04 - NO PERCENTILE'[ENGAGED_DAYS])
 

And this is the measure I created which calulates the percentile based on ENGAGED_DAYS only....

Course_Activity_Percentile =
VAR EngDays =
[EngDays]
RETURN
IF(
HASONEVALUE('All Faculty Course Activity Percentile 2022-04-04 - NO PERCENTILE'[PERSON_CODE]),
COALESCE(
DIVIDE(
--Numerator (below) counts values that are < the students's active day count in the course
CALCULATE(
COUNTROWS('All Faculty Course Activity Percentile 2022-04-04 - NO PERCENTILE'),
FILTER(
ALLEXCEPT('All Faculty Course Activity Percentile 2022-04-04 - NO PERCENTILE','All Faculty Course Activity Percentile 2022-04-04 - NO PERCENTILE'[CANVAS_COURSE_CODE]),
'All Faculty Course Activity Percentile 2022-04-04 - NO PERCENTILE'[ENGAGED_DAYS] < EngDays
)
),
--Denominator (below) counts the total students in the course
CALCULATE(
COUNTROWS('All Faculty Course Activity Percentile 2022-04-04 - NO PERCENTILE'),
ALLEXCEPT('All Faculty Course Activity Percentile 2022-04-04 - NO PERCENTILE','All Faculty Course Activity Percentile 2022-04-04 - NO PERCENTILE'[CANVAS_COURSE_CODE])
)
),
0
)
)
 
Can anyone help me to incorporate this additional factor into the calculation.
 
Thanks very much for your help.
2 REPLIES 2
v-jingzhang
Community Support
Community Support

Hi @DHB 

 

The first idea came to me is to multiply a small number (e.g. 0.0001) to REQUESTS_PER_ACTIVE_DAY and add this result to ENGAGED_DAYS to create a new adjusted ENGAGED_DAYS column with this additional factor. In this way, the new ENGAGED_DAYS column will not have duplicated values. Then you can use this new column in your percentile measure instead. 

new ENGAGED_DAYS = 'tablename'[REQUESTS_PER_ACTIVE_DAY] * 0.0001 + 'tablename'[ENGAGED_DAYS]

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

Thank you @v-jingzhang. It doesn't matter that some people might have the same results in both measures as they can be given the same percentile in that case.  Adding the two numbers together would also mean that one loses primacy over the other.

Helpful resources

Announcements
Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.