Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago

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

 

6 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous 

    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.

    • Anonymous's avatar
      Anonymous
      Not applicable

      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

       

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

    • Anonymous's avatar
      Anonymous
      Not applicable

      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

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Anonymous 

        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.