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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
KarenFingerhut
Responsive Resident
Responsive Resident

Create Sample Size in DAX

Hi there

 

Happy Friday everyone 

 

Can someone help me please? I'm trying to calculate a sample size value from a dataset. For example below

 

My overall total count is 24074

I want a 95% confidence

margin of error of 3%

 

I know my end figure should be 1022. (I used survey monkey site to get this figure) But for the life of me I dont know how to replicate this figure in DAX so I don't need to hard code it in and change it every time my main fogure of 24074 increases or decreases.

 

Done anyone know how to create this i DAX please...... I'm stumped

 

Many thanks

Karen

 

 

1 ACCEPTED SOLUTION
Shahid12523
Community Champion
Community Champion

Sample Size Required =
VAR N = COUNTROWS( 'YourTable' )
VAR Z = 1.96
VAR p = 0.5
VAR E = 0.03
VAR n0 = ( Z * Z * p * (1 - p ) ) / ( E * E )
VAR nCorr = ( N * n0 ) / ( N + n0 - 1 )
RETURN
ROUNDUP( nCorr, 0 )

Shahed Shaikh

View solution in original post

3 REPLIES 3
Kedar_Pande
Super User
Super User

  

Here's the DAX for the sample size calculation:

Sample Size =
VAR Population = 24074
VAR Z = 1.96 // 95% confidence
VAR p = 0.5 // proportion
VAR e = 0.03 // margin of error
VAR Numerator = (Z * Z * p * (1 - p)) / (e * e)
VAR Denominator = 1 + ((Z * Z * p * (1 - p)) / (e * e * Population))
RETURN
DIVIDE(Numerator, Denominator)
 

Replace 24074 with COUNTROWS(YourTable) to make it dynamic. This will give you ~1022.

 
💡 If this helped, please give Kudos 👍 or mark it as a Solution .
Best regards,
Kedar
🌐 Connect on LinkedIn: https://www.linkedin.com/in/kedar-pande

@KarenFingerhut

Shahid12523
Community Champion
Community Champion

Sample Size Required =
VAR N = COUNTROWS( 'YourTable' )
VAR Z = 1.96
VAR p = 0.5
VAR E = 0.03
VAR n0 = ( Z * Z * p * (1 - p ) ) / ( E * E )
VAR nCorr = ( N * n0 ) / ( N + n0 - 1 )
RETURN
ROUNDUP( nCorr, 0 )

Shahed Shaikh

@Shahid12523 

You are a genius, thank you so much. This is ace

Have a fabulous weekend, you've made me very happy

Kind regards

Karen

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.