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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
AviramWeiss
Helper I
Helper I

Percentile among averages

Hi everyone,

 

I have a table with such a structure:

 

Country    City    Sales    
USANYC100
USALA150
USAChicago200
UKLondon50
UKManchester100
FranceParis200
FranceNice300

 

I created a dashboard in which the user can choose the country as a page filter.

One of the components in this page is a Dial Gauge, in which I want to show the average sales of this country, and define the target values as 25th and 75th percentiles (sales in that range will be shown in green, above and below in red).

 

I created 2 measures and defined them as the gauge's target values:

25th percentile=PercentileX.EXC('Table',[Sales],0.25)

75th percentile=PercentileX.EXC('Table',[Sales],0.75)

 

This works fine, but I discovered that the average of all countries is always in the range of 25th-75th percentiles.

So what I want to do is calculate the average per country, and then redefine my measures to show the 25th/75th percentiles among the averages.

 

In the above example, it would be something like:

Country   Average sales   
USA150
UK75
France150

 

And then show percentiles of this table.

 

Any idea how to do that?

 

Thank you all in advance,

Aviram

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@AviramWeiss Try:

25th percentile = 
  VAR __Table = GROUPBY('Table',[Country],"Average Sales",AVERAGEX(CURRENTGROUP(),[Sales])
  VAR __Result = PERCENTILEX.EXC(__Table,[Average Sales],0.25)
RETURN
  __Result


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Super User
Super User

@AviramWeiss Try:

25th percentile = 
  VAR __Table = GROUPBY('Table',[Country],"Average Sales",AVERAGEX(CURRENTGROUP(),[Sales])
  VAR __Result = PERCENTILEX.EXC(__Table,[Average Sales],0.25)
RETURN
  __Result


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Works like a charm. Thank you very much!

 

For proper documentation, I had to put the GroupBy in a Calculate clause, to add a RemoveFilter (otherwise it always gave the result of the specific chosen country).

 

Thanks again.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

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