Forum Discussion
issues with RETURN statement from variables
- 11 months ago
I don't think that this is calculating what you want it to. The Total, Selection and External variables will not be recalculated for each iteration of Company Name. In DAX variables are not really variable, they are constants which are only calculated once.
If you wish to recalculate for each company then you would need to move the variables inside the SUMX.
Nicpet0 , Try using
VAR Total =
CALCULATE(
[Invoiced Quantity (Base) LYTD],
KEEPFILTERS(
Customer[Customer Posting Group] IN {"Group", "Group_SBU", "Retail", "Wholesale", "Grower"}
)
)
VAR External =
CALCULATE(
[Invoiced Quantity (Base) LYTD],
KEEPFILTERS(
Customer[Customer Posting Group] IN {"Retail", "Wholesale", "Grower"}
)
)
VAR Selection =
IF(
SELECTEDVALUE('Type of Sales'[Intercompany Sales]) = "On",
Total,
External
)
RETURN
SUMX(
VALUES('Company'[Company Name]),
IF(
'Company'[Company Name] = "", // Ensure this condition is correct
(Selection * 0.45359) / 1000,
Selection / 1000
)
)
Thanks your input
Yes the condition is correct. Nothing changes for me, since the code is the exact same as before