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
Jingspat
Frequent Visitor

Display Random Subset of Data

I have a table with thousands of rows.  Instead of displaying all the items, I would like to display 10 random rows of data every time to report loads.  Is there an easy way to accomplish this?

 

Regards,

 

JingSpat

1 ACCEPTED SOLUTION

hi @Jingspat

 

You may use RAND() in DAX either as a calculated column but I would prefer a measure as RAND in a measure is not always recalculated (reference). 

 

I tested how RAND works in a measure.  Here's what I did:

  • Add an index column to your table in power query. Apply query changes to load the updated table. This is so we can have one unique value for each row in your table.
  • Create a measure
    ramdom measure = RAND()
  • Add desired fields to a table including the index column.
  • Go to Visualizations pane > Fields > Visual level filters
  • Selected Top N under filter type. Show  Top 10 items. Drag random measure to By Value.

 










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

9 REPLIES 9
danextian
Super User
Super User

hi @Jingspat

 

Which one is your goal?

-select just 10 random rows in power query and then load it to the model

-randomly choose 10 rows of the dataset already loaded to the model










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

@danextian Sorry for not being clear.  I am relatively new to all this and am not sure of the proper terminology yet.  I am using a table visualization that returns thousands of rows and then adds a scroll bar on the report, but I just want it to display 10 randomly selected rows of data and no scroll bar.  I believe this correlates to your second scenario "randomly choose 10 rows of the dataset already loaded to the model."

 

Thanks so much!

hi @Jingspat

 

You may use RAND() in DAX either as a calculated column but I would prefer a measure as RAND in a measure is not always recalculated (reference). 

 

I tested how RAND works in a measure.  Here's what I did:

  • Add an index column to your table in power query. Apply query changes to load the updated table. This is so we can have one unique value for each row in your table.
  • Create a measure
    ramdom measure = RAND()
  • Add desired fields to a table including the index column.
  • Go to Visualizations pane > Fields > Visual level filters
  • Selected Top N under filter type. Show  Top 10 items. Drag random measure to By Value.

 










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

I can't seem to change the Visual level filter to anything other than "is less than" - it won't let me click the drop down box, but I can enter a value.  What am I doing wrong?

Untitled.png

 

Hi @Jingspat,

 

There is no Top N option for measures.  Please select Index and then choose Top N under filter types then drag random measure to By Value.










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Sorry for not getting it! I still can't change the filter type of Index:

 

Untitled.png

 

Here is the modeling tab for the Index column:Untitled.png

 

 

 

 

are you not seeing this option?

topN.png










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

I wasn't.  I just updated to the latest version and now it is working!  Thank you so much for the help!!!!

 

Appreciate it!

It didn't come to my mind that you might be using an older version of PBI Desktop but I'm glad to have helped.









Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

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.