Forum Discussion

E_Hutch's avatar
E_Hutch
Frequent Visitor
4 years ago
Solved

Pull Random 3% of Data

Good Morning!   I have a table of data that includes sales data, including the Customer Number and details of purchase. I would like to create a new table that pulls a random 3% (rounded up) of row...
  • E_Hutch's avatar
    4 years ago

    Alright, I remember how I did this previously. Took me a while, but I knew it could be done. Foregoing the half Red and half Blue on my wishlist, the way to create a new table with a random n% of rows from an existing table is to create a measure within the existing table as follows (using 3% as an example)

     

     3% = CALCULATE(DISTINCTCOUNT('Table1'[Order Number])*.03)

     

    Then create a new Table as using that measure:

     

    3% = SAMPLE('Table1'[3%], 'Table1',0)

     

    Then I can create a table visual based off of my new table, and add a slicer to select the Customer I want and it will pull a random 3% of that customer's orders. 

     

    Thanks all hope this helps someone else.