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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

running total per year

Hello Community,

 

I would appreciated your help withe the below.

 

I want to

  • find the running total value
  • create a graph its progress through all years

Especially when it comes to the graph, I want to be able to filter it by year or number of years, without impacting the running total calculation.

 

My source table is

ProjectYearValue
PR12020100
PR12021200

PR2

201950
PR2202075
PR22021100
PR3202195
PR32022105
PR32023120
PR42023100
 
 
 

I want to create this table.

YearAggregated Value
201950
2022225
2021620
2022725
2023945

 

Kind regards,

 

George

2 ACCEPTED SOLUTIONS
AlB
Super User
Super User

Hi @Anonymous 

Best to use a date table instead. Try this:

Measure =
VAR maxYear_ =
    MAX ( Table1[Year] )
RETURN
    CALCULATE ( SUM ( Table1[Value] ), Table1[Year] <= maxYear_ )

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

View solution in original post

amitchandak
Super User
Super User

@Anonymous , Try a measure like

measure = calculate(sum(Table[Value]), filter(allselected(Table), Table[Year] <=max(Table[Year])))

View solution in original post

8 REPLIES 8
AlB
Super User
Super User

@Anonymous 

In maxYear_ you get the current year in the filter context, the one in the current row of your visual. 

The Table1[Year] <= maxYear_ part then tells the CALCULATE to compute  SUM ( Table1[Value] ) over all the years that are equal or smaller than the current year.

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

 

Anonymous
Not applicable

thank you @AlB , for me is always very helpful to also know the logic behind the solution, kind regards.

AlB
Super User
Super User

@Anonymous 

the solution above does not use a date table

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

amitchandak
Super User
Super User

@Anonymous , Try a measure like

measure = calculate(sum(Table[Value]), filter(allselected(Table), Table[Year] <=max(Table[Year])))

Anonymous
Not applicable

Thank you @amitchandak 

 

Your proposal worked just fine.

 

May I only ask to elaborate more on the logic behind your solution? 

 

I also follow your LinkedIn posts , extremely helpful !

 

Thank you

 

George

AlB
Super User
Super User

Hi @Anonymous 

Best to use a date table instead. Try this:

Measure =
VAR maxYear_ =
    MAX ( Table1[Year] )
RETURN
    CALCULATE ( SUM ( Table1[Value] ), Table1[Year] <= maxYear_ )

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

Anonymous
Not applicable

Thank you @AlB 

 

Your proposal worked out perfectly.

 

Can I only ask how the variable maxYear interacts with CALCULATE in order to produce the correct result?

 

Thank you,

 

George

Anonymous
Not applicable

Hello @AlB , is there a way to resolve this without using a date table? Thank you

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors