Forum Discussion

0Experience's avatar
0Experience
Icon for Helper III rankHelper III
2 years ago
Solved

SUM using DAX for each year

Hello everyone,   I have a table with two columns: "Year" and "Sum of Data". Basically, the "Sum of Data" column shows the total amount for each year.   Now, I'm trying to get the same total usin...
  • v-yanimei-msft's avatar
    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.