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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.