Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Product | Date | QuantityDemand |
A | 1/05/2019 | 58 |
A | 18/03/2019 | 24 |
B | 2/04/2020 | 52 |
C | 7/05/2021 | 63 |
C | 2/05/2021 | 100 |
A | 3/10/2020 | 63 |
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?
Solved! Go to Solution.
Hi @Anonymous ,
You can use what-if parameter.
Then create the following separate table.
Table 2 = DISTINCT('Table'[Product])
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])
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.
Hi @Anonymous ,
You can use what-if parameter.
Then create the following separate table.
Table 2 = DISTINCT('Table'[Product])
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])
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.
@v-stephen-msft 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?
@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
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
99 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
102 | |
87 | |
64 |