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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
ysf
Helper I
Helper I

How to dynamically fetch sample data, using whatif parameter value or parameter value

Hi 

 

I have created a sample table using the Dax sample

Sample data = SAMPLE(30, FILTER('Table 1', 'Table 1'[Field] = "Values"),0) 

This works fine.

 

After that I have created a WhatIf Parameter so that i could use it to pull the data to a certain record count.

What if Parameter : 

Sample Pull = GENERATESERIES(0, 200, 1)
-> 
Measure :
Sample Pull Value = SELECTEDVALUE('Sample Pull'[Sample Pull],30)

 

I have then used the parameter value to generate the sample data.

Sample data = SAMPLE('Sample Pull'[Sample Pull Value], FILTER('Table 1', 'Table 1'[Field] = "Value"),0)

Have also tried the below .

 

In this example it seems to only pickup the default value from the what if parameter which is in my case 30 as written in the code above.

Sample Agric DDA =
VAR
PULL = 'Sample Pull'[Sample Pull Value]
RETURN
SAMPLE(PULL, FILTER('Table 1', 'Table 1'[Field] = "Value"),0)
 
In these examples it returns nothing
Sample Agric DDA =
VAR
PULL = VALUE(SELECTEDVALUE('Sample Pull'[Sample Pull]))
RETURN
SAMPLE(PULL, FILTER('Table 1', 'Table 1'[Field] = "Value"),0)
 
Sample Agric DDA = Sample( VALUE(SELECTEDVALUE('Sample Pull'[Sample Pull])), FILTER('Table 1', 'Table 1'[Field] = "Value"),0)
 
All I need is to dynamically allow end users to extract however many records they'd like to sample for their puroposes.
 
7 REPLIES 7
Icey
Community Support
Community Support

Hi @ysf ,

 

Can the method provided by @Mariusz meet your requirements?

 

 

 

Best Regards,

Icey

Mariusz
Community Champion
Community Champion

Hi @ysf 

 

SAMPLE returns a table and both columns and tables are loaded when on data load/refresh, therefore, you will not be able to make an impact on it with a measure as the data has loaded already.

 

You can create a Power Query parameter and combine it with SAMPLE  DAX function I guess.

 

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

Hi @Mariusz 

 

I have created a a parameter via PowerQuery but gives the same results when using its selected value.

the main intention is to allow for end users to decrease or increase the number of records to sample.

Mariusz
Community Champion
Community Champion

Hi @ysf 

 

Please see the attached file with an example of how to combine Power Query Parameters with DAX SAMPLE function

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

Thanks @Mariusz this helps in that I can change the paramenter value on the service myself, but it still needs more work if the report consumers want to change the parameter value so as increase the rows returned. I am guessing its not available right now.

 

 

Mariusz
Community Champion
Community Champion

Hi @ysf 

 

Yes, unfortunately, the only way I know of change the parameters in the service is by going to settings of the dataset.

You can create an Idea for this here if no one has yet as it seems like a good one.

 

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

Mariusz
Community Champion
Community Champion

Hi @ysf 

 

Please see the attached file with a solution that combines what-if parameters and Table visual filtered by Measure. Hope this is close enough to what you need.

 

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn


 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.