Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more.
Get startedGrow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.
Am trying to calculate this measure and currently it is giving correct answer. however i noticed one thing. in the below measure if i replace all the SUM(StockOnHand[Qty]) with variable SalesForEachMaterial it doest not give correct answer
Solved! Go to Solution.
@pavansada08143 wrote:... if i replace all the SUM(StockOnHand[Qty]) with variable SalesForEachMaterial it doest not give correct answer
If you replace ALL the references it definitely not give you the same answer as keeping the SUM(StockOnHand[Qty]) references inline. This is because variables are evaluated once in the scope in which they are declared and the value for them is stored. The second time you reference this expression it is inside a CALCULATE() call, the CALCULATE will not have any effect on the value of the variable as the value for it has already been stored so changing the filter context does not do anything.
So you would either need to leave that second reference in place or create an additional variable for the AllSelected version of "SalesForEachMaterial" that has the result of the calculate statement
eg.
@pavansada08143 wrote:... if i replace all the SUM(StockOnHand[Qty]) with variable SalesForEachMaterial it doest not give correct answer
If you replace ALL the references it definitely not give you the same answer as keeping the SUM(StockOnHand[Qty]) references inline. This is because variables are evaluated once in the scope in which they are declared and the value for them is stored. The second time you reference this expression it is inside a CALCULATE() call, the CALCULATE will not have any effect on the value of the variable as the value for it has already been stored so changing the filter context does not do anything.
So you would either need to leave that second reference in place or create an additional variable for the AllSelected version of "SalesForEachMaterial" that has the result of the calculate statement
eg.
Thats suggestion worked out well. however i have encountered another problem during my drill up. At the heighest level i am finding incorrect values. Meaning At the 1st level i am trying to do the Style level total against Grand total.
Finally i was able to pass through the hickups and get the output as expected by using below measure.
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Ask questions in Eventhouse and KQL, Eventstream, and Reflex.
User | Count |
---|---|
87 | |
78 | |
62 | |
61 | |
60 |
User | Count |
---|---|
160 | |
114 | |
100 | |
74 | |
65 |