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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Segment data based on percentile by group

Greetings,

 

I have a table like this one:

GROUPVALUE
A1
B10
A2
A2
A3
B12
B15
A2
B18
B14

 

I´d like to find percentiles by group so I can filter the data that is too high or too low for each group:

GROUPVALUEP20P80FILTER
A1130
B1010180
A2131
A2131
A3130
B1210181
B1510181
A2131
B1810180
B1410181

 

Segmented data:

GROUPVALUE
A2
A2
B12
B15
A2
B14

 

Anyone knows how to find percentiles by group either on DAX or Power Query? I´ve been looking but haven´t found something like this.

 

Thanks, best regards,

Alejandro.

1 ACCEPTED SOLUTION
lc_finance
Solution Sage
Solution Sage

Hi @Anonymous ,

 

 

You can download my proposed solution here.

 

Here are the DAX formulas for the 3 calculated columns:

 

1) 20th percentile

Perc 20 = 
VALUE(PERCENTILEX.EXC(
    FILTER('Table' ,[GROUP]=EARLIER('Table'[GROUP]) )
    ,[VALUE] , 0.2))

2) 80th percentile

Perc 80 = 
VALUE(PERCENTILEX.EXC(
    FILTER('Table' ,[GROUP]=EARLIER('Table'[GROUP]) )
    ,[VALUE] , 0.8))

3) Filter

Filter = IF([VALUE]>[Perc 20] && [VALUE]<[Perc 80],1,0)

Finally, here is a screenshot of what it looks like.

Percentiles-table

 

Does this help you?

 

Do not hesitate if you have more questions.

 

LC

Interest in Power BI and DAX templates? Check out my blog at www.finance-bi.com

View solution in original post

2 REPLIES 2
lc_finance
Solution Sage
Solution Sage

Hi @Anonymous ,

 

 

You can download my proposed solution here.

 

Here are the DAX formulas for the 3 calculated columns:

 

1) 20th percentile

Perc 20 = 
VALUE(PERCENTILEX.EXC(
    FILTER('Table' ,[GROUP]=EARLIER('Table'[GROUP]) )
    ,[VALUE] , 0.2))

2) 80th percentile

Perc 80 = 
VALUE(PERCENTILEX.EXC(
    FILTER('Table' ,[GROUP]=EARLIER('Table'[GROUP]) )
    ,[VALUE] , 0.8))

3) Filter

Filter = IF([VALUE]>[Perc 20] && [VALUE]<[Perc 80],1,0)

Finally, here is a screenshot of what it looks like.

Percentiles-table

 

Does this help you?

 

Do not hesitate if you have more questions.

 

LC

Interest in Power BI and DAX templates? Check out my blog at www.finance-bi.com

Anonymous
Not applicable

That works, thanks for the help.

 

I got this error with the production data though:

The percentile value should be in the range 1/(N+1)..N/(N+1) inclusive, where N is the number of data values

error.png

 

Changing from PERCENTILEX.EXC to PERCENTILEX.INC solved it. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.