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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
haroonzulfiqar1
New Member

Store parameters values in a variable

Hey folks,
I am working on a code where I am making summarize table in which I am comparing the performance 'X' days before and 'X' days after the date of installation. It is working fine. Now I want to X days value from the user and store in to a variable so User can see the before and after according to their needs. I created paramater called Vardays but when I am storing the value of parameter in a variable called daysbeforeafter;it is not working but when I give a number to that variable then its working
Does anyone has any idea How I can achieve this? Thanks

haroonzulfiqar1_0-1693566220784.pngharoonzulfiqar1_1-1693566243847.png

 

6 REPLIES 6
abpgupta
Continued Contributor
Continued Contributor

You can create a separate measure for user input variable and use it to troubleshoot as well as pass in final measure to see what's actually being passed. 

Hey,
Appreciate your response
Here you can see the table and slicer and card which is showing the parameter value. Vardays is paramter column and Varday Value is measure which is: SELECTEDVALUE (VarDays[Vardays). Sum of test is a column which I made in summarize table and inserted the variable value in that where I am storing the VarDays value in variable called "Daysbeforeafter"
As we can see, parameters are working in canvas but in the backend code, parameters are not storing in the variable (As we can see the column of 'Sum of test' which is coming as blank) and I guess because of that blank, its not filtering anything

Capture.PNG

Hi @haroonzulfiqar1 

The calculated table is the static table, it will not change by the paramater, so when you select one paramater, it will give the blank value, because the paramater is not existd in the table, you can consider to create a virtual table by using measure, then filter the related value from the virtual table,

e.g 

dateinrange =
VAR daysbefore =
    SELECTEDVALUE ( VarDays[VarDays] )
VAR _virtualtable =
    the function you create the table
RETURN
    MINX (
        FILTER (
            _virtualtable,
            [Meterkey] IN VALUES ( Flow_Value_Daily_Consumption[Meterkey] )
        ),
        [Sum of Test]
    )

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hey 
Thanks its really great
But [Sum of test] is just for testing, I am filtering the table by passing parameter value in the variable if you can see the DAX above where VAR daysbeforafter=SELECTEDVALUE(VarDays[VarDays]),

Any number in that variable will go through dax and change the function accordingly, is that make sense?

I really appreciate your support
Thanks you

v-xinruzhu-msft
Community Support
Community Support

Hi @haroonzulfiqar1 

How did you display the paramater in slicer, the paramater will return blank if you set the slicer type to between or other types that contain multiple paramaters. the selectedvalue() only return single value when you selected only one value, you can set the paramater type to 'single value' or 'dropdown' and select only one value. you can refer to the following link to know more about the selectedvalue() function.

SELECTEDVALUE function - DAX | Microsoft Learn

 

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hey,
Appreciate your response
Here you can see the table and slicer and card which is showing the parameter value. Vardays is paramter column and Varday Value is measure which is: SELECTEDVALUE (VarDays[Vardays). Sum of test is a column which I made in summarize table and inserted the variable value in that where I am storing the VarDays value in variable called "Daysbeforeafter"
As we can see, parameters are working in canvas but in the backend code, parameters are not storing in the variable (As we can see the column of 'Sum of test' which is coming as blank) and I guess because of that blank, its not filtering anything

 

Capture.PNG

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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

Top Solution Authors
Top Kudoed Authors