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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
andyln33
Frequent Visitor

Cumulative Count Previous Year

https://imgur.com/akzvvqU 

 

Cumlative count is displaying great for this year. But how do I go about showing the previous year? You can see in the screenshot above I'm looking to compare 2 years, cumulatively.  (This YTD, and last year entirely)

 

CUMULATIVE = CALCULATE(
COUNT ( IncidentInjury[id] ),
FILTER (
ALLSELECTED ( IncidentInjury ),
IncidentInjury[created_at] <= MAX ('IncidentInjury'[created_at] )
))
1 ACCEPTED SOLUTION
stevedep
Memorable Member
Memorable Member

This is your code:

Cum2 = TOTALYTD(CALCULATE(COUNT(IncidentInjury[id]));IncidentInjury[created_at];ALL(IncidentInjury))
Cum3 = TOTALYTD(CALCULATE(COUNT(IncidentInjury[id]));SAMEPERIODLASTYEAR(IncidentInjury[created_at]);ALL(IncidentInjury))

as seen here:

ytdcum.jpg

Please mark as solution if so, thumbs up for the effort would be great.

Kind regards, Steve. 

View solution in original post

5 REPLIES 5
stevedep
Memorable Member
Memorable Member

This is your code:

Cum2 = TOTALYTD(CALCULATE(COUNT(IncidentInjury[id]));IncidentInjury[created_at];ALL(IncidentInjury))
Cum3 = TOTALYTD(CALCULATE(COUNT(IncidentInjury[id]));SAMEPERIODLASTYEAR(IncidentInjury[created_at]);ALL(IncidentInjury))

as seen here:

ytdcum.jpg

Please mark as solution if so, thumbs up for the effort would be great.

Kind regards, Steve. 

Thanks Steve!

 

What's the filter/syntax to cut the data off at the MAX date? (For example, I want the line to stop at June)

 

success.png

 

 

 

 

 

Yes, using a Date Dimension table. Although PBI might be trying to use the internal as well.

 

Andy

lbendlin
Super User
Super User

SAMEPERIODLASTYEAR() gives you the entire previous year's date range. That is somewhat unexpected, but it perfectly fits what you want (however questionable the reasoning behind that is).

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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