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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
DataScope06
Helper I
Helper I

Sales running total for specific years

I would like to compare a specific year's running total of sales by month to another year's running totals by month.

 

For example, the running total of 2021 compared to 2022, with month on the x-axis.

 

My data structured is shown in the abbreviated table below. Underneath the table is a sketch of what I would like the chart look like.

 

DateSales
1/2/2021500
2/1/2021400
6/20/2021700
1/2/2022400
3/1/2022600
4/1/2022300

 

DataScope06_0-1672677908451.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @DataScope06 ,

 

You could create a calendar and then create a measure to calculate the running total.

Calendar = ADDCOLUMNS(CALENDAR(MIN('Table'[Date]),MAX('Table'[Date])),"Year",YEAR([Date]),"MonthNumber",MONTH([Date]),"Month",FORMAT([Date],"MMMM"))

Select the Month column and sort by the MonthNumber column.

vstephenmsft_0-1672910094028.png

The relationship is as follows.

vstephenmsft_1-1672910126909.png

Create the measure.

Running Total = CALCULATE(SUM('Table'[Sales]),FILTER(ALLSELECTED('Calendar'),[Year]=MAX('Calendar'[Year])&&[MonthNumber]<=MAX('Calendar'[MonthNumber])))

 

vstephenmsft_2-1672910153786.png

 

You can dowload my attachment for more details.

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

7 REPLIES 7
Anonymous
Not applicable

Hi @DataScope06 ,

 

You could create a calendar and then create a measure to calculate the running total.

Calendar = ADDCOLUMNS(CALENDAR(MIN('Table'[Date]),MAX('Table'[Date])),"Year",YEAR([Date]),"MonthNumber",MONTH([Date]),"Month",FORMAT([Date],"MMMM"))

Select the Month column and sort by the MonthNumber column.

vstephenmsft_0-1672910094028.png

The relationship is as follows.

vstephenmsft_1-1672910126909.png

Create the measure.

Running Total = CALCULATE(SUM('Table'[Sales]),FILTER(ALLSELECTED('Calendar'),[Year]=MAX('Calendar'[Year])&&[MonthNumber]<=MAX('Calendar'[MonthNumber])))

 

vstephenmsft_2-1672910153786.png

 

You can dowload my attachment for more details.

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

This worked! Thank you. 

 

Also, part of my issues was due to discrepancy between fact and calendar table date formats. Specifically this was because my fact table date was in a datetime format. I found a blog post with details about the way this effects the relationship. Anyone having that issue can see the blog here: Relationship Issues With DateTime Data Types in Power BI — Havens Consulting

DataScope06
Helper I
Helper I

The thread linked below might have a solution posted by @amitchandak, however I am unable to download the workbook.

Solved: Running Total Chart over Multiple Years - Microsoft Power BI Community

Anonymous
Not applicable

For previous year:

CALCULATE(SUM(FactsTable[Sales]), SAMEPERIODLASTYEAR('Date'[DateKey]))

Then it's just a matter of using the sales column and applying a hidden filter so that it only shows data from the current year.

Thanks @Anonymous, what if I want to show running totals by specific year, rather than the previous year?

Anonymous
Not applicable

CALCULATE(
    SUM(Fatture[Importo Pagato]),
    DATEADD(
DATESINPERIOD(
'Date'[DateKey],
"yourDesiredStartDate",
nOfIntervals,
interval
),
nOfIntervals, //in multiples of 12 for months
MONTH/YEAR
)
)

 This should allow you to get any year you want.

You could also use FILTER(YEAR(DateKey)=yourDesiredYear).

I can't get your solution to work. Still searching for the solution to this issue.

 

Reminder the goal is to display the running total of sales for individual years on the same chart.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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.