Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi,
Im trying to create a dax measure that will calculate the sum of the absolute differences of products planned and sold for each product on each day. This is quite easy on a spreadsheet but for some reason am struggling in Power BI.
This is my schema:
My table looks like this:
Im able to get the correct answer for eash line item but when it comes to the total Ive tried a few approaches and all seem to not work.
Ive looked at:
Solved! Go to Solution.
It seems like you're trying to calculate the absolute aggregate difference between planned and sold quantities for each product on each day in Power BI using DAX. Your DAX measure looks mostly correct, but it seems you might need to adjust the context in which it operates. You should consider iterating over each product to calculate the absolute difference. Here's how you can modify your DAX measure:
AbsoluteDifference =
SUMX (
VALUES ( 'Sales'[RecipeID] ), -- Iterate over each distinct RecipeID
VAR PlannedQty =
CALCULATE (
SUM ( 'Planned Menus'[Qty] ),
FILTER ( 'Planned Menus', 'Planned Menus'[RecipeID] = 'Sales'[RecipeID] )
)
VAR SoldQty =
CALCULATE (
SUM ( 'SaleLine'[Quantity] ),
FILTER ( 'SaleLine', 'SaleLine'[RecipeID] = 'Sales'[RecipeID] )
)
RETURN
ABS ( PlannedQty - SoldQty )
)
Here's a breakdown of what this measure does:
This measure should provide you with the absolute aggregate difference between planned and sold quantities for each product on each day in Power BI. Make sure to adjust the table and column names as per your actual data model.
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.
It seems like you're trying to calculate the absolute aggregate difference between planned and sold quantities for each product on each day in Power BI using DAX. Your DAX measure looks mostly correct, but it seems you might need to adjust the context in which it operates. You should consider iterating over each product to calculate the absolute difference. Here's how you can modify your DAX measure:
AbsoluteDifference =
SUMX (
VALUES ( 'Sales'[RecipeID] ), -- Iterate over each distinct RecipeID
VAR PlannedQty =
CALCULATE (
SUM ( 'Planned Menus'[Qty] ),
FILTER ( 'Planned Menus', 'Planned Menus'[RecipeID] = 'Sales'[RecipeID] )
)
VAR SoldQty =
CALCULATE (
SUM ( 'SaleLine'[Quantity] ),
FILTER ( 'SaleLine', 'SaleLine'[RecipeID] = 'Sales'[RecipeID] )
)
RETURN
ABS ( PlannedQty - SoldQty )
)
Here's a breakdown of what this measure does:
This measure should provide you with the absolute aggregate difference between planned and sold quantities for each product on each day in Power BI. Make sure to adjust the table and column names as per your actual data model.
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.
Thanks for your help
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
9 | |
8 | |
8 | |
7 |
User | Count |
---|---|
13 | |
12 | |
11 | |
11 | |
8 |