Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

User input to calculate a measure dynamically

Hi Community,

 

I want to allow the report end user to provide input based on which a measure is calculated.

Report looks like following:

The user can select Empcode from parameterized slicer 'Emp'. I would like to have another parametrized slicer to get user input for 'Number of Leaves taken' (a numeric value 1 to 20) by the corresponding Empcode selected in slicer 'Emp'. Then I want to create a measure:

Hours Worked = Hrs per week - Number of leaves taken.

How can I achieve this?

My Pbi file:  https://1drv.ms/u/s!Ag919_pO_UKrgRFm2OqHum4jDUhC?e=hDpXyw

 

TIA

  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi Anonymous ,

     

    According to my understanding, the [Number of Leaves taken] is a what-if parameter as well,right?

    To my knowledge,when you create a what-if parameter, a measure is automatically generated.So you could use it directly like this:

     

    Hours Worked = 
    VAR hrsPerWeek =
        CALCULATE (
            SUM ( Emp[Hrs per week] ),
            FILTER ( 'Emp', 'Emp'[Emp Code] = SELECTEDVALUE ( Emp[Emp Code] ) )
        )
    RETURN
        hrsPerWeek -[Number of Leaves taken Value]

     

    The final output is shown below:

    Here is the pbix file.

     

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

5 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    According to my understanding, the [Number of Leaves taken] is a what-if parameter as well,right?

    To my knowledge,when you create a what-if parameter, a measure is automatically generated.So you could use it directly like this:

     

    Hours Worked = 
    VAR hrsPerWeek =
        CALCULATE (
            SUM ( Emp[Hrs per week] ),
            FILTER ( 'Emp', 'Emp'[Emp Code] = SELECTEDVALUE ( Emp[Emp Code] ) )
        )
    RETURN
        hrsPerWeek -[Number of Leaves taken Value]

     

    The final output is shown below:

    Here is the pbix file.

     

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