Forum Discussion

ysf's avatar
ysf
Helper I
6 years ago

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

  • Mariusz's avatar
    Mariusz
    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

     

    • ysf's avatar
      ysf
      Helper I

      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.

  • Icey's avatar
    Icey
    Community Support

    Hi ysf ,

     

    Can the method provided by Mariusz meet your requirements?

     

     

     

    Best Regards,

    Icey