Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
Hi Community
im trying to create a DAX calculation that evaluates invoiced quantity based on my "Selection" variable. My issue is the return statement, where it wont divide my number with 1000 which i use to convert from kg to tonnes. How can i change my code to. Any tips for the overall structure of my code will also be helpful.
Se snippet below for context.
Thank you!
Solved! Go to Solution.
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
)
)
Proud to be a Super User! |
|
Thanks your input
Yes the condition is correct. Nothing changes for me, since the code is the exact same as before
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.
Hi @Nicpet0 ,
Thanks for reaching out to the Microsoft fabric community forum.
Thanks for your prompt response
wanted to follow up and confirm whether you’ve had the opportunity to review the information provided by @johnt75 , @bhanu_gautam . If you have any questions or need further clarification, please don’t hesitate to reach out.
We appreciate your collaboration and support!
Best regards,
Lakshmi.
Hi @Nicpet0 ,
We’d like to confirm whether your issue has been successfully resolved. If you still have any questions or need further assistance, please don’t hesitate to reach out. We’re more than happy to continue supporting you.
We appreciate your engagement and thank you for being an active part of the community.
Best Regards,
Lakshmi.
Hi @Nicpet0 ,
We’d like to confirm whether your issue has been successfully resolved. If you still have any questions or need further assistance, please don’t hesitate to reach out. We’re more than happy to continue supporting you.
We appreciate your engagement and thank you for being an active part of the community.
Best Regards,
Lakshmi.