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
ylin88_waters
Helper I
Helper I

DAX to calculate the percentile group dynamically

Hi
I have a column "SalesPotential" with a value for each customer (one row one customer). I want to create a measure to assign all customers to four groups based on their percentiles of SalesPotential, like ">75th" for those SalesPotential on the top 25%, ">50th" for those >=50% and <75%, and so on. I want to keep all filters in this calculation. For example, if I have a slicer on country and users select "USA", this percentile group will be only for the customers in USA.

 

I am new to DAX and tried the following but failed:

 

Potential Percentile=
var P75 =PERCENTILEX.INC( [Potential], 0.75 )
var P50 =PERCENTILEX.INC( [Potential], 0.50 )
var P25 =PERCENTILEX.INC( [Potential], 0.25 )
SWITCH(TRUE(),
[Potential] >= P75, ">= 75th Percentile",
[Potential] >= P50, ">= 50th Percentile",
[Potential] >= P25, ">= 25th Percentile",
"<25th Percentile" )

 

After I typed "TRUE(),", Power BI only popped out measures for me, no columns so I can't get the column "Potential" I need. I think I did something wrong. Can anybody help on this DAX? Thanks a lot!!

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@ylin88_waters If this is a measure then you are going to need to wrap an aggregation around your column references like MAX or MIN. So:

var P75 =PERCENTILEX.INC( [Potential], 0.75 )
var P50 =PERCENTILEX.INC( [Potential], 0.50 )
var P25 =PERCENTILEX.INC( [Potential], 0.25 )
SWITCH(TRUE(),
MAX([Potential]) >= P75, ">= 75th Percentile",
MAX([Potential]) >= P50, ">= 50th Percentile",
MAX([Potential]) >= P25, ">= 25th Percentile",
"<25th Percentile" )

@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

1 REPLY 1
Greg_Deckler
Super User
Super User

@ylin88_waters If this is a measure then you are going to need to wrap an aggregation around your column references like MAX or MIN. So:

var P75 =PERCENTILEX.INC( [Potential], 0.75 )
var P50 =PERCENTILEX.INC( [Potential], 0.50 )
var P25 =PERCENTILEX.INC( [Potential], 0.25 )
SWITCH(TRUE(),
MAX([Potential]) >= P75, ">= 75th Percentile",
MAX([Potential]) >= P50, ">= 50th Percentile",
MAX([Potential]) >= P25, ">= 25th Percentile",
"<25th Percentile" )

@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.