Reply
babajat
Frequent Visitor
Partially syndicated - Outbound

SUM VALUES HIGHER THAN PERCENTILE

Hi!

I have a table with many rows, each corresponding to one order identified via "ID". Each order has the "NAME" of the person that ordered it. "NAME" is a value that can be repeated between orders.


I managed to get a formula that gives me the 90th percentile of orders grouped by person:

 

PERCENTILE = 
VAR SummaryTable =
    SUMMARIZE (
        'table',
        table[Name],
        "Number", DISTINCTCOUNT (table[ID])
    )
RETURN
PERCENTILEX.INC (
        SummaryTable,
        [Number],
        0.90
    )

 


Now I would like to get the sum of orders placed by people who ordered above the 90th percentile.

I tried with the following formula but "SUM" can't find the "NUMBER" column. I've been trying to solve this problem for hours...

 

 

TOT OVER PERCENTILE = 
VAR SummaryTable =
    SUMMARIZE (
        'table',
        table[Name],
        "Number", DISTINCTCOUNT (table[ID])
    )
var percentile =     PERCENTILEX.INC (
        SummaryTable,
        [Number],
        0.90
    )
RETURN
CALCULATE(SUM(Number), FILTER(SummaryTable, number > percentile))

 

Thanks in advance! 

1 ACCEPTED SOLUTION

Syndicated - Outbound

Hi @babajat ,

 

I think you can update your measure as below.

TOT Over Percentile 1 =
VAR SummaryTable =
    SUMMARIZE ( 'TABLE', [Name], "Number", DISTINCTCOUNT ( 'TABLE'[ID] ) )
VAR percentile =
    PERCENTILEX.INC ( SummaryTable, [Number], 0.90 )
RETURN
    SUMX ( FILTER ( SummaryTable, [Number] > percentile ), [Number] )

 

Best Regards,
Rico Zhou

 

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

 

View solution in original post

3 REPLIES 3
babajat
Frequent Visitor

Syndicated - Outbound

Nevermind, i've just managed to do it with SUMX and FILTER:

TOT Over Percentile = 
VAR SummaryTable =
    SUMMARIZE (
        'TABLE',
        TABLE[Name],
        "Number", DISTINCTCOUNT (Table[ID])
    )
var percentile =     PERCENTILEX.INC (
        SummaryTable,
        [Number],
        0.90
    )
RETURN
SUMX (FILTER(SUMMARIZE ( Table, [Name], "Number1", DISTINCTCOUNT( Table[ID] )), [Number1] > percentile),
    [Number1])

 

I imagine it's a "dirty" solution so if anyone has any better ideas I'm open to suggestions.

Thanks anyway!

Syndicated - Outbound

Hi @babajat ,

 

I think you can update your measure as below.

TOT Over Percentile 1 =
VAR SummaryTable =
    SUMMARIZE ( 'TABLE', [Name], "Number", DISTINCTCOUNT ( 'TABLE'[ID] ) )
VAR percentile =
    PERCENTILEX.INC ( SummaryTable, [Number], 0.90 )
RETURN
    SUMX ( FILTER ( SummaryTable, [Number] > percentile ), [Number] )

 

Best Regards,
Rico Zhou

 

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

 

Syndicated - Outbound

Much cleaner, thank you!

avatar user

Helpful resources

Announcements
March PBI video - carousel

Power BI Monthly Update - March 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)