Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Hello all,
New Power BI user.
Tried some examples found on the web but I cannot seem to apply them to this scenario.
I have a dataset of purchases for various branches around the United States. I am looking to extract a percentage of them for auditing purposes. More precisely, a percentage by state. For example:
The states have the following number of records:
Alabama 1000
Nebraska 250
California 3750
I want to extract 10% of the records. So
100 of Alabama
25 of Nebraska
375 for California
I have tried creating a column using Number.Random & Number.RandomBetween but every record gets the same random number so I can't use it to select say "the top 10%".
Any guidance would be greatly appreciated.
Solved! Go to Solution.
RAND function return a random value for each row. Please refer the screenshot below.
Regards,
Charlie Liao
Perhaps look at Table.Range
https://msdn.microsoft.com/en-us/library/mt260780.aspx
Also, maybe Table.SelectRows and provide a condition that the row index mod 10 is 0?
https://msdn.microsoft.com/en-us/library/mt260810.aspx
Thank you smoupre.
These have promise. But I need to assign a random value to each record first. I think I need to create a new column and assign a random value to each record. Tried using Number.Random but it provides the same value to each row. Once, I have the values assigned your suggestion will be a good next step so I appreciate that. I may have to go the DAX route.
Appreciate your help.
RAND function return a random value for each row. Please refer the screenshot below.
Regards,
Charlie Liao
Thank you, Charlie.
I was actually looking for a solution to part of the query step which is probably not the correct way of thinking.
I appreciate your feedback.
Brian
Have a look at this post, in particular Colin Banfield's reply:
Hmm, you could do this in DAX if you perhaps have a query by state and then create a calculated table where you grab a number of records less than some index. So, in Alabama create a calculated table of and index <= 100. Kind of hacky. Will try to think of a more elegant solution.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 48 | |
| 43 | |
| 39 | |
| 19 | |
| 17 |
| User | Count |
|---|---|
| 67 | |
| 63 | |
| 30 | |
| 30 | |
| 23 |