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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
CornelisV
Helper II
Helper II

Calculation median, Q1 and Q2 from grouped data in a new table (descriptive statistics)

Dear all,

 

I'm struggling for finding a way to calculate Median, Q1 and Q2 from a table that is categorized with 'Class':

ClassValue
A20
A25
A40
A13
A15
B99
B101
B105
B88
B91
B99

 Q1 and Q3 are quartiles from a dataset, where Q2 = Median.

The output should be, in a new table:

ClassMedian Q1Q3
A201525
B9993100.5

 

Could you please demonstrate how to do create a new table?

 

Best regards,

 

Cornelis

2 ACCEPTED SOLUTIONS

Hi @CornelisV ,

 

Please try code as below to create measures.

Median = MEDIAN('Table'[Value])
Q1 = PERCENTILE.INC('Table'[Value],0.25)
Q3 = PERCENTILE.INC('Table'[Value],0.75)

Result is as below.

vrzhoumsft_0-1728028844351.png

 

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

CornelisV
Helper II
Helper II

Hello Rico Zhou,

 

Thank you for your support, that looks promising.

Could you please expalin me how dit you split into Class A and Class B with the Median, Q1 and Q3 output as listed above?

 

Best regards,

 

Cornelis

View solution in original post

5 REPLIES 5
CornelisV
Helper II
Helper II

Hello Rico Zhou,

 

Thank you for your support, that looks promising.

Could you please expalin me how dit you split into Class A and Class B with the Median, Q1 and Q3 output as listed above?

 

Best regards,

 

Cornelis

CornelisV_0-1728394284187.png

So, use a Quick calculation, apply like this 

Q1 = PERCENTILE.INC('Source'[Value],0.25)
and the calculation will be automatically done by group.
Ritaf1983
Super User
Super User

Hi @CornelisV 

You did not specify the quarter for each row, which makes the calculation logic unclear. Could you please provide the missing details to clarify the logic?

 

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Hi @Ritaf1983 

 

Thank you for your message.

It is not the quartile of each row, but the quartile from a serie.

so serie with class = A have the values in order of the next row:

13  15  20  25  40

The Median = 20, perfect in the middle of a row.

Quartile 1 is 25 % of the row, so Q1 = 15

Quartile 3 is 75 % of the row, so Q3 = 25

 Does this make any sense?

 

Best regards,

 

Cornelis

 

Hi @CornelisV ,

 

Please try code as below to create measures.

Median = MEDIAN('Table'[Value])
Q1 = PERCENTILE.INC('Table'[Value],0.25)
Q3 = PERCENTILE.INC('Table'[Value],0.75)

Result is as below.

vrzhoumsft_0-1728028844351.png

 

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.

 

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.