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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

How to change values based on the slicer selection using DAX

ProductDateQuantityDemand
A1/05/201958
A18/03/201924
B2/04/202052
C7/05/202163
C2/05/2021100
A3/10/202063

 

I have a data set that looks like the above and I want to create a what-if scenario and change the values of quantity demand based on the Product selection of slicer. For instance, if someone selects A, the Quantity demand for Product A must be set to zero and calculate the total Quantity demand. This is to see what would the total demand quantity be if the demand for a specific product or products is zero. I want to create a measure that changes the value of quantity demand and return the Total Quantity Demand dynamically.

 

Here is my trial below, but no luck yet.

 

 

 

 

 

 

 

 

Deletion = 
var selection = 
    SELECTEDVALUE(Table[Product])
    Return
    SWITCH(TRUE(),
    selection = HASONEVALUE(Data[Product])
    ,VALUES(Data[QuantityDemand])=0)

 

 

 

 

 

 

 

 

Can anyone please help me with this?

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

You can use what-if parameter.

8.png

 

Then create the following separate table.

Table 2 = DISTINCT('Table'[Product])

9.png

 

At last, create the following measure.

Total Quantity Demand = CALCULATE(SUM('Table'[QuantityDemand]),FILTER(ALL('Table'),[Product]<>SELECTEDVALUE('Table 2'[Product])))+SELECTEDVALUE('Quantity demand'[Dynamic Quantity demand])

10.gif

 

Best Regards,

Stephen Tao

 

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

3 REPLIES 3
Anonymous
Not applicable

Hi @Anonymous ,

 

You can use what-if parameter.

8.png

 

Then create the following separate table.

Table 2 = DISTINCT('Table'[Product])

9.png

 

At last, create the following measure.

Total Quantity Demand = CALCULATE(SUM('Table'[QuantityDemand]),FILTER(ALL('Table'),[Product]<>SELECTEDVALUE('Table 2'[Product])))+SELECTEDVALUE('Quantity demand'[Dynamic Quantity demand])

10.gif

 

Best Regards,

Stephen Tao

 

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

@Anonymous  there seems to be an error?

 

Quantities w/o dynamic slicer do not fit.

Sum of A = 145 (not 215)

Sum of B = 52 (not 308)

Sum of C = 163 (not 197)

 

Is there an issue with the measure?

amitchandak
Super User
Super User

@Anonymous , can you share expected output

 

like quantity other than selected 

 

calculate(sum(Data[QuantityDemand]), filter( Data, not(data[Product] in allselected(data[Product] ))))

 

You can control this better if you have an independent table for the product

example Need of an Independent Table in Power BI: https://youtu.be/lOEW-YUrAbE

 

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

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.