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
Anonymous
Not applicable

Sample Size from Row Count - #DAX #Stats #RandomSample

Hello!

I need to calculate a sample size based on the row count of a filtered table.

I'm trying to automate part of our bad debt estimation process. I currently pull about 20 aging reports, then filter the table, take the row count and put it into an online calculator to get the sample size - then do some more filtering using RANDOM in Excel to get a sample table that is then analyzed for bad debt.

I've pulled all of my reports into P BI and want to use the SAMPLE function to get my table, but I want ot calculate the sample size based on the row count of the filtered table. does anyone know how to do that?

Here are some parameters that I enter into the online calculator...

 

  • Population = row count of >90
  • Confidence level 95%
  • Proportion .5
  • Confidence interval .05

 

I'm filtering my table by company and aging >90...

 

Table =
SAMPLE(10, FILTER('Aging Invoice Detail', 'Aging Invoice Detail'[AgingFromDocDate]>89 ||'Aging Invoice Detail'[Entity]= "CDMT"),0)
 
Thank you!
 
5 REPLIES 5
V-lianl-msft
Community Support
Community Support

Hi @Anonymous ,
 
This thread can be able to help you solve such problems
 
Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
kentyler
Solution Sage
Solution Sage

VAR row_count = countrows(AgingInvoiceDetail)
Table =
SAMPLE(row_count, FILTER('Aging Invoice Detail', 'Aging Invoice Detail'[AgingFromDocDate]>89 ||'Aging Invoice Detail'[Entity]= "CDMT"),0)

if there are filters on the table you may need to wrap the countrows in a calculate()
Calculate(countrows(AgingInvoiceDatil),ALL(AgingInvoiceDetail))

I'm a personal Power Bi Trainer I learn something every time I answer a question

The Golden Rules for Power BI

  1. Use a Calendar table. A custom Date tables is preferable to using the automatic date/time handling capabilities of Power BI. https://www.youtube.com/watch?v=FxiAYGbCfAQ
  2. Build your data model as a Star Schema. Creating a star schema in Power BI is the best practice to improve performance and more importantly, to ensure accurate results! https://www.youtube.com/watch?v=1Kilya6aUQw
  3. Use a small set up sample data when developing. When building your measures and calculated columns always use a small amount of sample data so that it will be easier to confirm that you are getting the right numbers.
  4. Store all your intermediate calculations in VARs when you’re writing measures. You can return these intermediate VARs instead of your final result  to check on your steps along the way.






Did this post answer your question? Mark it as a solution so others can find it!

Help when you know. Ask when you don't!




Join the conversation at We Talk BI find out more about me at Slow BI


Anonymous
Not applicable

Hi,
Thank you for your reply.
I'm actually looking for a statistical sample size based off of the population of the entire row count... I don't want to use the row count as the sample size.
Also while you're unsolicited feedback is helpful, I don't really think that the community is the place to be posting those things unless they are asked for. I think most of us in the community have probably used some of the same resources. Just a suggestion.
Thank you,
Kim

Kim

Thanks for your feedback. Statistics is one of my weak points.

Will reconsider my extended tag line.

Ken Tyler





Did this post answer your question? Mark it as a solution so others can find it!

Help when you know. Ask when you don't!




Join the conversation at We Talk BI find out more about me at Slow BI


Anonymous
Not applicable

yes, stats isn't a strong point for me either... thank you for taking the time to respond.

 

Kim

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