Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

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?
  • 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.

1 Reply

  • HotChilli's avatar
    HotChilli
    Community Champion

    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.