Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

First N rows

Hi,   I have a table with some clients and i want to reduce that table in order to get a random 10% sample of clients. How can I do it? (It must be in DAX)   Thanks!
  • OwenAuger's avatar
    7 years ago

    Hi Anonymous,

     

    You can write something like either of these expressions (assuming your original table is called Clients):

     

    Client Sample =
    SAMPLE ( 10, ADDCOLUMNS ( Clients, "rand", RAND () ), [rand] )
    
    Client Sample =
    TOPN ( 10, ADDCOLUMNS ( Clients, "rand", RAND () ), [rand] )

     

    Both of these add a column [rand] to the resulting table, which could be removed with SELECTCOLUMNS if needed.

     

    Regards,
    Owen