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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Paulo123
Frequent Visitor

Running Total lastyear

hi, I wanted the measure to return the accumulated value of the last year. but when I filter for example the year 2021, it should return the accumulated value for the year 2020 but it returns blank. The measure:
LY_V_LI_ACUM =
CALCULATE (SUMX (VALUES(Dados[Mês]),[LY_VL]),
FILTER ( ALLSELECTED ( Dados), Dados[Data Valor] <= MAX(CALENDARIO[Date])
))
4 ACCEPTED SOLUTIONS
ValtteriN
Super User
Super User

Hi,

I recommend creating a normal RT calculation like: 
RT =

CALCULATE (SUM (Dados[Mês])
ALLSELECTED ( Dados), Dados[Data Valor] <= MAX(CALENDARIO[Date])
)

Then create LY measure like this:
[RT LY] = 
CALCULATE([RT],SAMEPERIODLASTYEAR(CALENDARIO[Date]))

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

Paulo123
Frequent Visitor

hi @ValtteriN 

keeps returning blank

View solution in original post

Sorry about that, Here is a revised version:

RT =
var maxdate = MAX(CALENDARIO[Date]) return

CALCULATE (SUM (Dados[Mês])
ALL( CALENDARIO), CALENDARIO[Date] <= maxdate
)

Also for future reference check this article by SQLBI about the topic: https://www.sqlbi.com/articles/computing-running-totals-in-dax/ 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

V-lianl-msft
Community Support
Community Support

Hi @Paulo123 ,

 

Sorry, It's hard to give an accurate formula without detail information. SAMEPERIODLASTYEAR  works well in my model. Please refer to this pbix

 

 

Best Regards,
Liang
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

4 REPLIES 4
V-lianl-msft
Community Support
Community Support

Hi @Paulo123 ,

 

Sorry, It's hard to give an accurate formula without detail information. SAMEPERIODLASTYEAR  works well in my model. Please refer to this pbix

 

 

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

Paulo123
Frequent Visitor

hi @ValtteriN 

keeps returning blank

Sorry about that, Here is a revised version:

RT =
var maxdate = MAX(CALENDARIO[Date]) return

CALCULATE (SUM (Dados[Mês])
ALL( CALENDARIO), CALENDARIO[Date] <= maxdate
)

Also for future reference check this article by SQLBI about the topic: https://www.sqlbi.com/articles/computing-running-totals-in-dax/ 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




ValtteriN
Super User
Super User

Hi,

I recommend creating a normal RT calculation like: 
RT =

CALCULATE (SUM (Dados[Mês])
ALLSELECTED ( Dados), Dados[Data Valor] <= MAX(CALENDARIO[Date])
)

Then create LY measure like this:
[RT LY] = 
CALCULATE([RT],SAMEPERIODLASTYEAR(CALENDARIO[Date]))

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.