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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

DAX Query

I am trying to write a dax query to calculate percentile for a value in a sub-group. Below is my query. When I run it the field for  Employee Percentile Rate  returns blanks.

e120405_0-1665602417474.png

 

Employee Percentile Rate =
VAR TotalScore =Table1[Score]
RETURN
IF(
HASONEVALUE(Table1[Employee ID]),
COALESCE(
DIVIDE(
--Numerator (below) counts values that are < the EMP's Score in the Employee ID
CALCULATE(
COUNTROWS(Table1),
FILTER(
ALLEXCEPT(Table1,Table1[Employee ID]),
Table1[Score] < TotalScore
)
),
--Denominator (below) counts the total employees in the Employee ID segment
CALCULATE(
COUNTROWS(Table1),
ALLEXCEPT(Table1, Table1[Employee ID])
)
),
0
)
)
9 REPLIES 9
mangaus1111
Solution Sage
Solution Sage

sorry for the misunderstanding, but I need to know which are your expected values in Column [Employee Percentile Rate]. Can you send us a sample table?

 

mangaus1111_0-1666019613846.png

 

Anonymous
Not applicable

Service LineIncentive PoolEmployee IDFirst NameLast NameEligibility FactorEmployee Percintile Score
Customer Account ServicesCAS001BSE123037EricBurton3.75 
Customer Account ServicesCAS001BSE083568JamesOntiveros4.63 
Customer Account ServicesCAS001BSE095868JamesSt. Julien4.25 
Customer Account ServicesCAS001BSE130370JamesDiep3.76 
Customer Account ServicesCAS001COE127667JamesArtiga3.82 
Customer Account ServicesCAS001ICE115243JamesAdelakoun4 
Customer Account ServicesCAS001ICE112434JamesMenefee - PWE4.5 
Customer Account ServicesCAS001ICE113468JamesHughes4.75 
Customer Account ServicesCAS001ICE090711JamesVincent3.88 
Customer Account ServicesCAS001MRE169863JamesMcDonald4.88 
Customer Account ServicesCAS001MRE118293JamesNguyen4 
Capital ProjectsCIP001CPE160779RobertCarpy4.46 
Capital ProjectsCIP001CPE155001RobertBurroughs4.5 
Capital ProjectsCIP001CPe172462RobertAl Amari3.76 
Capital ProjectsCIP001CPe137368RobertHall4.25 
Capital ProjectsCIP001CPE167678RobertSanders3.88 
Capital ProjectsCIP001CPE168042RobertPatankar4 
Capital ProjectsCIP001CPE150729RobertDedeaux4.01 
Capital ProjectsCIP001CPe168057RobertLee4.75 
Capital ProjectsCIP001CPE174429RobertBurrell4 
Capital ProjectsCIP001CPE128238RobertO'Briant3.75 
Capital ProjectsCIP001CPE137141RobertWatson4 
Capital ProjectsCIP001CPE154894RobertCantu4.25 
Capital ProjectsCIP001CPE173676RobertGillespie4 
Capital ProjectsCIP001CPE168593RobertMcKee5 
Capital ProjectsCIP001CPE172387RobertPonton4 
Capital ProjectsCIP001CPE140164JohnDavidson3.75 
Directors OfficeDIR001LDE110055JohnLopez3.75 
Directors OfficeDIR001LDE123033JohnVuong3.76 
Directors OfficeDIR001LDE079892JohnAllen4.12 
Directors OfficeDIR003IRE139390JohnLuckenbach4 
Directors OfficeDIR003IRE166102JohnNelson4.67 
Directors OfficeDIR003IRE136984JohnWilson4.12 
Directors OfficeDIR006ITe167581JohnHussain3.75 
Directors OfficeDIR006ITe167935JohnMarcano4.58 
mangaus1111
Solution Sage
Solution Sage

Hi @Anonymous 

 

please let us know how is the formula for the percentile and then we provide you a DAX solution.

mangaus1111
Solution Sage
Solution Sage

Do you need something like this?

Employee IDColumn1ScoreEmployee Percentile Rate

E119848Capital Projects18,031
E119848Customer Account Services3,630,666666666666667
E119848Directors Office3,440,333333333333333
E153665Capital Projects12,371
E153665Directors Office4,130,666666666666667
E153665Houston Permitting Center4,080,333333333333333
E162855Capital Projects10,131
E162855Customer Account Serivces7,750,5
E098039Capital Projects16,991
E155642Capttal Projects15,251
mangaus1111
Solution Sage
Solution Sage

Hi @Anonymous ,

 

I can help you, but please let me know which are your expected numbers in Column [Percentile Rate]

 

Employee IDColumn1ScoreEmployee Percentile Rate

E119848Capital Projects18,030,666666666666667
E119848Customer Account Services3,630,333333333333333
E119848Directors Office3,440
E153665Capital Projects12,370,666666666666667
E153665Directors Office4,130,333333333333333
E153665Houston Permitting Center4,080
E162855Capital Projects10,130,5
E162855Customer Account Serivces7,750
E098039Capital Projects16,990
E155642Capttal Projects15,250
v-yanjiang-msft
Community Support
Community Support

Hi @Anonymous ,

Replace the HASONEVALUE function like this:

Employee Percentile Rate =
VAR TotalScore = Table1[Score]
RETURN
    IF (
        Table1[Employee ID] <> BLANK (),
        COALESCE (
            DIVIDE (
                --Numerator (below) counts values that are < the EMP's Score in the Employee ID
                CALCULATE (
                    COUNTROWS ( Table1 ),
                    FILTER ( ALLEXCEPT ( Table1, Table1[Employee ID] ), Table1[Score] < TotalScore )
                ),
                --Denominator (below) counts the total employees in the Employee ID segment
                CALCULATE (
                    COUNTROWS ( Table1 ),
                    ALLEXCEPT ( Table1, Table1[Employee ID] )
                )
            ),
            0
        )
    )

Get the result.

vkalyjmsft_0-1665626989774.png

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Using the Dax Query provided I get 0(s)  where there should be percentile values

Anonymous
Not applicable

Using the Dax Query provided I get 0(s)  where there should be percentile values

 

e120405_0-1666016724328.png

Expected values like this

Incentive PoolEmployee IDEmployee First NameEmployee Last NameEligibility FactorEmployee Percentile Score 
CAS001BSE083568RolandOntiveros4.0150.0% 
 E095868ClaytonSt. Julien00.0% 
 E122857OliviaAndrews00.0% 
 E123037EricBurton4.0150.0% 
 E130370SandyDiep00.0% 
 e157644SheldonDundy00.0% 
CAS001BS Total   8.02  
CAS001COE115990SandraMcDaniels3.9248.3% 
 E127667YasminArtiga4.1951.7% 
CAS001CO Total   8.11  
CAS001ICE090711VictorVincent3.8149.5% 
 E112434MarlonMenefee - PWE00.0% 
 E113468StacyHughes3.8850.5% 
 E115243HubertAdelakoun00.0% 
 E125206DanielSaenz00.0% 
 e156425NelsonBernard Jr.00.0% 
CAS001IC Total   7.69  
CAS001MRE063977IWilliams3.7619.1% 
 E094623RonaldCharles00.0% 
 E094629MygonneGabriel3.8819.7% 
 E095362KevinMosley00.0% 
 E105324JoeGarcia00.0% 
 E106179PatriciaSmith00.0% 
 E111102DracyUpson00.0% 
 E113112KevenKeys00.0% 
 E113574ArmandoMunoz00.0% 
 E115035PauletteLockridge420.4% 
 E118293Dat TanNguyen4.1321.0% 
 E119019MacarioAndrio3.8819.7% 
 E120112VietDuong00.0% 
CAS001MR Total   19.65  
Anonymous
Not applicable

Employee Percentile Value =
VAR EligibilityFactor = [Eligibility Factor]
RETURN
IF(
Table1[Eligibility Factor] <> BLANK (),
COALESCE(
DIVIDE(
--Numerator (below) counts values that are < the EMP's Score in the Incentive Pool
CALCULATE(
COUNTROWS(Table1),
FILTER(
ALLEXCEPT(Table1,Table1[Incentive Pool]),
Table1[Eligibility Factor] < Table1[Eligibility Factor]
)
),
--Denominator (below) counts the total employees in the Incentive Pool segment
CALCULATE(
COUNTROWS(Table1),
ALLEXCEPT(Table1, Table1[Incentive Pool])
)
),
0
)
)

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors