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
zaidmasad
Helper III
Helper III

Calculate the percentile for Cumulative total

Hello,

 

How can I calculate the 70th percentile for a cumulative data? My data looks as below:

Capture.JPG

 

I need to have for each country the 70th percentile ( how many attempt it takes to deliver 70% of the shipments)

 

Thanks,

Zaid

5 REPLIES 5
zaidmasad
Helper III
Helper III

@v-xjiin-msft thanks for your reply,

 

I have created this table from the data, and highlighted the value greater than 70%:

Capture.JPG

 

Now I need to find the exact number of how many attempts it takes 70% of the shipments.. Taking Belgium as an example, 70% percent of the shipment have between 0 and 1 attempts, I need to find that exact number of attempts.

 

In manual calculation to find the percentile what you do is:

 

P70 = (70/100)*Total number of records

 

Then you do interpolation to find the exact number.

 

 

Here is the finction I have used to find the cumulative percentage:

 

RunningTotal = 
CALCULATE (
 SUM ( Sheet1[Shipment Count] ),
 FILTER ( ALL ( Sheet1 ), Sheet1[Total Delivery Attempts] <= MAX ( Sheet1[Total Delivery Attempts] ) ),
 VALUES ( Sheet1[Destination Country] ),VALUES(Sheet1[Is Ecom]),VALUES(Sheet1[Customer Account Type])
)

 

The data I have looks as below:

 

 

Capture.JPG

@zaidmasad

 

Check this:

 

My sample data is like

11.PNG

 

Then to find the 70% percent of the shipment, I am checking the min Total Delivery Attempts of the Attempts over than 70%. Then we just need to count the records which Total Delivery Attempts <= the min Total Delivery Attempts.

 

MIN >70 Attempts =
CALCULATE (
    MIN ( Sheet1[Total Delivery Attempts] ),
    FILTER ( ALL ( Sheet1 ), Sheet1[RunningTotal] >= 70 ),
    VALUES ( Sheet1[Destination Country] ),
    VALUES ( Sheet1[Is Ecom] ),
    VALUES ( Sheet1[Customer Account Type] )
)
P70 =
CALCULATE (
    COUNTROWS ( Sheet1 ),
    FILTER ( ALL ( Sheet1 ), Sheet1[Total Delivery Attempts] <= [MIN >70 Attempts] ),
    VALUES ( Sheet1[Destination Country] ),
    VALUES ( Sheet1[Is Ecom] ),
    VALUES ( Sheet1[Customer Account Type] )
)

The result shows like this:

 

333.PNG

 

If my method doesn't satisfy your requirement, please kindly share us some more detailed sample data ( which we can copy and paste ). So that we can make proper tests.

 

Thanks,
Xi Jin.

Hi @v-xjiin-msft,

 

Yes, this is what I want. But I think there is something wrong in the calculations, shouldnt it be the 70th percentile as per you data 1 not 2, right?

 

Destination CountryIs EcomCustomer Account TypeTotal Delivery AttemptsShipment CountCumulative
BelgiumIs EcomEpayment022.02%
BelgiumIs EcomEpayment17981.82%
BelgiumIs EcomEpayment21192.93%
BelgiumIs EcomEpayment3597.98%
BelgiumIs EcomEpayment4198.99%
BelgiumIs EcomEpayment50.799.70%
BelgiumIs EcomEpayment60.299.90%
BelgiumIs EcomEpayment70.1100.00%
BelgiumIs EcomEpayment80100.00%
BelgiumIs EcomEpayment90100.00%
BelgiumIs EcomEpayment100100.00%
BelgiumIs EcomEpayment110100.00%
BelgiumIs EcomEpayment120100.00%

 

 

Also, I am facing a problem when the total delivery attempt is not repeated  in all of the groups, such as the below:

 

Is Ecom Destination Region Destination Country Customer Account Type Total Delivery Attempts Shipment Count

B2CMiddle EastSaudi ArabiaCOD037423
B2CMiddle EastSaudi ArabiaCOD13631
B2CMiddle EastSaudi ArabiaCOD2441
B2CMiddle EastSaudi ArabiaCOD327
B2CMiddle EastSaudi ArabiaCOD43
B2CMiddle EastSaudi ArabiaEpayment037351
B2CMiddle EastSaudi ArabiaEpayment111985
B2CMiddle EastSaudi ArabiaEpayment2625
B2CMiddle EastSaudi ArabiaEpayment326
B2BMiddle EastSaudi Arabianull050065
B2BMiddle EastSaudi Arabianull12967
B2BMiddle EastSaudi Arabianull2210
B2BMiddle EastSaudi Arabianull314
B2BMiddle EastSaudi Arabianull41
B2BMiddle EastSaudi Arabianull013552
B2BMiddle EastSaudi Arabianull11221
B2BMiddle EastSaudi Arabianull271
B2BMiddle EastSaudi Arabianull35

 

for the above, when it counts the cumulative for total delivery attempts "4", the numbers gets wrong, because the group "4" doesnt exist in all categories.

 

 

Thanks,

Zaid

Hi @zaidmasad,

 

Sorry for delayed reply.

 

=> Taking Belgium as an example, 70% percent of the shipment have between 0 and 1 attempts, I need to find that exact number of attempts.

 

I thought it means the 70th percentile means 0 and 1. If it is just 0. You can modify the expression to:

 

P70 =
CALCULATE (
    COUNTROWS ( Sheet1 ),
    FILTER ( ALL ( Sheet1 ), Sheet1[Total Delivery Attempts] < [MIN >70 Attempts] ),
    VALUES ( Sheet1[Destination Country] ),
    VALUES ( Sheet1[Is Ecom] ),
    VALUES ( Sheet1[Customer Account Type] )
)

Then for your second question, what did you mean you want to count the cumulative for total delivery attempts "4". Could you please share us your measure expression? And your shared sample data is a little werid. So for a same Is Ecom, Destination Region , Destination Country, Customer Account Typ, there will exists duplicated Total Delivery Attempts. Right? Like 

B2BMiddle EastSaudi Arabianull

 

Thanks,
Xi Jin.

v-xjiin-msft
Solution Sage
Solution Sage

Hi @zaidmasad,

 

I'm not quite understand about the 70th percentile for a cumulative data. What does this 70th percentile mean? What's the logic to calculate this percentile?

 

Since you have shared some sample data. What's your desired result based on this sample data?

 

Thanks,
Xi Jin.

 

 

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.

Top Solution Authors