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

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
Fyouri
Frequent Visitor

Problem with running total

I have a list where i keep track of the total number of hours worked in a company per month. I need to get a sum of the last 12 months  on each row. This is what i would want:

 

Date              Total Hours               Cumulated hours

1/1/2014                  5000                                   5000

1/2/2014                  6000                                 11000

..

1/12/2014               8000                                185000 (total of 1/1/2014 till 1/12/2014)

1/1/2015                 7000                                187000 (total of 1/2/2014 till 1/1/2015)

 

I don't really know if I should do this in a column or a Measure. This is what i have so far: Calculate(Sum('Table'[Total Hours]),DATEADD('Table'[Date],-1,YEAR)<'Table'[Date])). But this is not working. Can someone push me a bit in the right direction please?

 

1 ACCEPTED SOLUTION
sdjensen
Solution Sage
Solution Sage

You could try something like this:

 

CALCULATE(
	SUM( 'Table'[Total Hours] ),
	DATESBETWEEN(
		'DateTable'[Date],
		NEXTDAY ( SAMEPERIODLASTYEAR ( LASTDATE ( 'DateTable'[Date]) ) ),
		LASTDATE ( 'DateTable'[Date] )
	)
)
/sdjensen

View solution in original post

5 REPLIES 5
sdjensen
Solution Sage
Solution Sage

You could try something like this:

 

CALCULATE(
	SUM( 'Table'[Total Hours] ),
	DATESBETWEEN(
		'DateTable'[Date],
		NEXTDAY ( SAMEPERIODLASTYEAR ( LASTDATE ( 'DateTable'[Date]) ) ),
		LASTDATE ( 'DateTable'[Date] )
	)
)
/sdjensen

Sdjensen,

 

I tried this but this gives me just the same value as the column total hours.

Do you have a seperate table with all the dates from the first date in your data to the last and made a relationship between these 2 tables?

/sdjensen

Thanks Sdjensen,

 

I forgot to make a connection between the 2 tables. It works now.

Anonymous
Not applicable

Hi 

Try this 

Last6SalesNew:=IF(ISBLANK(sum(SalesData[SalesAmount])),BLANK(),
CALCULATE(sum(SalesData[SalesAmount]),
DATESBETWEEN(
Calendar[FullDate],
FIRSTDATE(PARALLELPERIOD(Calendar[FullDate], -6, MONTH)),
LASTDATE(PARALLELPERIOD(Calendar[FullDate], -1, MONTH))
), ALL(Calendar) ))

 

This gives me the sales for the previous six months from current month displayed in the pivot table or charts.

Replace the formulas with the columns in your data model.

This assumes a date table called as Calendar and is linked to the SalesData date field.

 

Best 

Cheenusing

Helpful resources

Announcements
Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors