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
h0ttamale
Frequent Visitor

Cumulative Running Totals for Prior Year (flat line only, want cumulative curve) in Chart

I have a flat line instead of a cummulative curve for a prior year measure calculation (black line in graph below). I'd like to see a cummulative curve, just like the current year (green line in graph below). I'm trying to graph cumulative running count on a line graph comparing prior year to current year count.

 

 

How to I display the black line as a running total curve?

 

The x-axis is week number.

 

Chart:

 

Image 3.pngImage 6.pngImage 7.png

 

Measures:

 

CumulativeQICY:

 

Image 9.png

 

CumulativeQIPY:

 

Image 11.png

 

I've tried incorporating sameperiodlastyear, dateadd and have failed.

 

Thanks in advance for all your help. I'm really looking forward to the responses. Thank you.

 

2 ACCEPTED SOLUTIONS
OwenAuger
Super User
Super User

Hi @h0ttamale

 

The beauty of time intelligence functions is that you can calculate an existing measure in an altered date context without having to rewrite the logic of the underlying measure.

 

I would write CumulativeQIPY like this:

 

CumulativeQIPY =
CALCULATE ( [CumulativeQICY], SAMEPERIODLASTYEAR ( 'Calendar'[Date] ) )

 

 

Since CumulativeQIPY is already working correctly, wrapping it in CALCULATE with SAMEPERIODLASTYEAR performs exactly the same calculation but in a date context one year earlier.

 

You could also use DATEADD ( 'Calendar'[Date], -1, YEAR ) in place of SAMEPERIODLASTYEAR ( 'Calendar'[Date] ).

 

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

View solution in original post

Hi @h0ttamale

 

Yes you're right.

 

In your original measure, having the condition YEAR ( 'Calendar'[Date] ) < MAX ( 'Calendar'[Year] ) meant you were effectively showing a cumulative total for all previous years, which wouldn't change within a given year (it also meant 'Calendar'[Date] <= MAX ( 'Calendar'[Date] ) was redundant.

 

In your visual, only 2017 was selected so your measure returned a cumulative total up to the end of 2016 for all dates.

 

If you had plotted multiple years, you would see the line step up to a new constant each year.

 

Owen 🙂


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

View solution in original post

3 REPLIES 3
OwenAuger
Super User
Super User

Hi @h0ttamale

 

The beauty of time intelligence functions is that you can calculate an existing measure in an altered date context without having to rewrite the logic of the underlying measure.

 

I would write CumulativeQIPY like this:

 

CumulativeQIPY =
CALCULATE ( [CumulativeQICY], SAMEPERIODLASTYEAR ( 'Calendar'[Date] ) )

 

 

Since CumulativeQIPY is already working correctly, wrapping it in CALCULATE with SAMEPERIODLASTYEAR performs exactly the same calculation but in a date context one year earlier.

 

You could also use DATEADD ( 'Calendar'[Date], -1, YEAR ) in place of SAMEPERIODLASTYEAR ( 'Calendar'[Date] ).

 

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

That's awesome. Thanks!

 

Do you know why my original code wasn't working as expected? My thought was that it was because the x-axis started at Week 1 2017 and during Week 1 2017, the 2016 activities alredy took place and thus for every week after week 1 2017, the 2016 activities didn't change...

Hi @h0ttamale

 

Yes you're right.

 

In your original measure, having the condition YEAR ( 'Calendar'[Date] ) < MAX ( 'Calendar'[Year] ) meant you were effectively showing a cumulative total for all previous years, which wouldn't change within a given year (it also meant 'Calendar'[Date] <= MAX ( 'Calendar'[Date] ) was redundant.

 

In your visual, only 2017 was selected so your measure returned a cumulative total up to the end of 2016 for all dates.

 

If you had plotted multiple years, you would see the line step up to a new constant each year.

 

Owen 🙂


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

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.