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
babajat
Frequent Visitor

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

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

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!

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.

 

Much cleaner, thank you!

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.