Forum Discussion
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
- Anonymous5 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
- AnonymousNot 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. - amitchandakSuper User
Anonymous , You can try What if parameters
- AnonymousNot applicable
amitchandak yes, I have tried 'What if parameter'. The 'Emp' slicer is a what is parameter.
- amitchandakSuper User
Anonymous , No of leaves can be what if. Emp Code, You might use Text filter https://appsource.microsoft.com/en-us/product/power-bi-visuals/WA104381309?src=office&tab=Overview