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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

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:

Capture_2402.JPG

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

1 ACCEPTED SOLUTION
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:

2.26.4.slicer.PNG

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.

View solution in original post

5 REPLIES 5
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:

2.26.4.slicer.PNG

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.

amitchandak
Super User
Super User

@Anonymous , You can try What if parameters

https://docs.microsoft.com/en-us/power-bi/desktop-what-if

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandak  yes, I have tried 'What if parameter'. The 'Emp' slicer is a what is parameter.

@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

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandak  I can't make the text filter work in this case. 'The issue is I can't establish relationshi between my table & 'No: of leaves' what if parameter. No: of leaves' is just a numeric input value corresponding to an Empcode that I want to use in the measure calculation. 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors