Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It 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.