Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Numeric Range Parameter selected value not recognized in random sampling

Hi, I am trying to have a numeric range parameter (going from 1 to the number of rows in the source table) that can be adjusted to randomly sample a table. I tried to follow the logic of OwenAuger in https://community.powerbi.com/t5/Desktop/DAX-random-sample/m-p/386571 . but run into the issue that the Selectedvalue function only returns the alternate value. 

 

My random sample is a calculated table using the following logic:

 

Random Selection =
VAR SampleSize = SELECTEDVALUE(Parameter[Parameter])
VAR TableWithRand =
    ADDCOLUMNS ( SourceTable, "Rand", RAND () )
RETURN
    TOPN ( SampleSize, TableWithRand, [Rand] )
 
Where Parameter is a numeric range defined as 
Parameter = GENERATESERIES(0, COUNTROWS(SourceTable), 1)
 
The SelectedValue(Parameter[Parameter]) does not work, but if I provide an alternate value (SELECTEDVALUE(Parameter[Parameter], 3) then the sample size is indeed set to 3. 
 
What am I doing wrong that the parameter value selected in a slicer cannot be read to alter the sample size?
1 ACCEPTED SOLUTION
HotChilli
Super User
Super User

A calculated table (or column) cannot respond to a slicer.  If you can find a way of doing what you want with a measure, then it will react.

View solution in original post

1 REPLY 1
HotChilli
Super User
Super User

A calculated table (or column) cannot respond to a slicer.  If you can find a way of doing what you want with a measure, then it will react.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.