Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Show sum of values in a year as a constant for all years in a table

Hello, I am trying to create a measure that calculates the sum of all values for a specific year as a constant and then report that number in every single row, regardless of the filters and slicers used in the workbook. Below is a table with an example of what I need (2019 SUM)

 

Year and Month come from "Calendar" table, Color comes from "Color" table and Value comes from "Value" table, the table shown below is the result of putting the different measures together in a visualization , and I need to obtain the red column (final).

 

YearMonthColorValue2019 SUM
2019Junblue0.5504.795
2019Julred0.7804.795
2019Augorange0.9984.795
2019Sepwhite0.8754.795
2019Octblack0.6544.795
2019Novpurple0.9384.795
2020Jungreen0.6374.795
2020Julpink0.3634.795
2020Augblack0.4984.795
2020Sepgray0.8774.795
2020Octmagenta0.9874.795
2020Novyellow0.5434.795
2021Junsilver0.7894.795
2021Julgold0.3674.795
2021Augbronce0.4674.795
2021Sepcoal0.9844.795
2021Octchocolate0.7634.795
2021Novbrown0.7774.795

 

My main problem is that the data is under live connection so I'm not able to creat tables, nor import files, queries, or even manage relationships so my options are limited and I can only create measures.

 

I have tried a query using VAR "..."= calculate()....... RETURN..... and sumx(summarize()) but I'm not able to get the result I need.

5 REPLIES 5
Anonymous
Not applicable

How do I add a switch? let's say if I wanted to calculate that difference for all years and the ones to come? Since this is a live connection file, it is updated monthly and the idea is for it to work in future years.

Anonymous
Not applicable

Hello, it did work, however, when I try to build another table using another year (2018) the final table considers absolutely all values instead of comparing just 2018 values with the 2019 values, please picture below.

 

YearMonthColorValueFY19 SUMDifference
2018Junblue 4.795-4.795
2018Julred 4.795-4.795
2018Augorange 4.795-4.795
2018Sepwhite 4.795-4.795
2018Octblack 4.795-4.795
2018Novpurple 4.795-4.795
2018JunIndigo0.6654.795-4.130
2018JulPink0.7784.795-4.017
2018AugCyan0.8884.795-3.907
2018SepDark0.9094.795-3.886
2018OctLight0.9874.795-3.808
2018Novlime0.8894.795-3.906

 

 

When I try to do the difference between the values of colors in 2018 minus the 2019 value, I get the wrong table, I just need to see the 2018 difference, not all of them.

 

Eventually, I am going to use this difference to count how many colors in 2018 where below 2019, and then a % which I can chart by month.

 

Hi @Anonymous ,
Not sure if this what you would like, but it should move you along the path.

sum1.PNG

 

Either 2019 or 2018 =
var _curYear = MAX(Table2[Year])

var _20calc= CALCULATE([Total Values], All(Table2),Table2[Year]=2020)
var _19calc =CALCULATE([Total Values], All(Table2),Table2[Year]=2019)

Return If (_curYear = 2019, _19calc, If(_curYear =2020, _20calc)) // or to do all years you can add a switch)

 


Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Nathaniel_C
Community Champion
Community Champion

Hi @Anonymous ,
Here is your measure 

Sum of 2019 values = CALCULATE([Total Values], All(Table2),Table2[Year]=2019)


sum.PNG


Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




mahoneypat
Microsoft Employee
Microsoft Employee

Please try this measure expression, assuming your Year column is an integer.  If not, add double quotes around 2019.

 

2019 Sum = CALCULATE(SUM(Value[Value]), ALL('Calendar'), ALL(Color[Color]), 'Calendar'[Year] = 2019)

 

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors