Forum Discussion
SUM using DAX for each year
- 2 years ago
Hi 0Experience ,
Thank you for reaching out and providing a detailed description of your issue. Based on your question, I've tested your DAX (just by creating a test table and a new measure) and analyzed why. The specific data in the test table will be provided in a later step.
As the following picture, we can see the result of Measure and Sum of Sales is same.
So, I wonder if you've used a filter. Because if you've used a filter, it will show different results like the following picture.
The function in your formula is to keep the filter context on the Year column while removing all other filter contexts. I'm going to give you ways to make sure that your calculations are made explicit every year, and thus possibly avoid some contextual issues.
Please follow these steps:
1.Create the test table Table. The specific data is in the following picture.
2.Create visualizations. Add Year and SalesData to Columns, then select Sum.
3. Right-click Table, select New Measure and input:
SUM using DAX = SUMX( VALUES('Table'[Year]), CALCULATE(SUM('Table'[SalesData])) )Then, add SUM using DAX to Columns and the outcome is in the following picture.
Best Regards,
Caroline Mei
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I tried but it doesn't work the way give. It takes the individual one, not the sum for each year. See the screenshot.
It seems to me that you are using more information within your table. Like there is more than just the year and the sum.
Can't you even take a screen shot of the filters and fields present?
- 0Experience2 years ago
Helper III
In my original table I have too many column but in this (output) table I have only these 3 columns
Thanks for your time, and for trying to help me.- Mattiar2 years ago
Resolver I
Then it could be a relationship problem.
Do you have the data dimension that relates to the fact table with a one-to-many relationship?
Is the column on which you make the relation the classic given column?Unfortunately my help without pbix is a bit limited. But hopefully we can find a solution to this anomaly.
- 0Experience2 years ago
Helper III
I didn't use any relationship. I have too many columns but they are on the same table (no columns are coming from other table as part of relationship).
Thanks again