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

View all the Fabric Data Days sessions on demand. View schedule

Reply
apatnola
Helper I
Helper I

Running total for a prior year based on slicer Date selections

I have a formula that works great for calculating a running total of transactions between two dates in a date slicer:

 

Transactions Cumulative Current Period = CALCULATE(sum('Confirmed Transactions'[Transaction Count]),filter(ALLSELECTED(Dates),Dates[Date]<=max(Dates[Date])))
 
Works great.
 
I'd also like to also display a cumulative total for the same period from last year (depending on what the slicer values are). I cannot seem to find a good solution for that.
 
I'd like for users to be able to select a week or a month or any date range and be able to see the current cumulative total for that date range and prior year cumulative total.
 
Any assistance would be most appreciated.
8 REPLIES 8
v-lid-msft
Community Support
Community Support

Hi @apatnola ,

 

We can create a new measure based on your measure to meet your requirement.

 

Transactions Cumulative Current Period (last year) =
IF (
    COUNTROWS ( 'Confirmed Transactions' ) > 0,
    CALCULATE (
        [Transactions Cumulative Current Period],
        SAMEPERIODLASTYEAR (
            FILTER ( ALLSELECTED ( Dates[Date] ), 'Dates'[Date] <= MAX ( Dates[Date] ) )
        )
    )
)

 

Then we can get the result like this,

 

33.png34.png

 

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that we have shared?


Best regards,

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you, I tried:

 

Transactions **bleep** Prior Period = If (COUNTROWS('Confirmed Transactions') > 0 ,CALCULATE([Transactions **bleep** Current Period],SAMEPERIODLASTYEAR(filter(ALLSELECTED(Dates[Date],Dates[Date]<=max(Dates[Date]))))))
 
I got the error message that too few arguments were passed to the filter function.
 
I then tried
Transactions **bleep** Prior Period = If (COUNTROWS('Confirmed Transactions') > 0 ,CALCULATE([Transactions **bleep** Current Period],SAMEPERIODLASTYEAR(filter(ALLSELECTED(Dates),Dates[Date]<=max(Dates[Date])))))
 
I got the error message that a table expression containing more than one column was specified in the call function 'Sameperiodlastyear'. This is not supported.

Hi @apatnola ,

 

How about the result after you follow the suggestions mentioned in my original post?Could you please provide more details about it If it doesn't meet your requirement?


Best regards,

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @apatnola ,

 

We found that it miss a right brackets in the first measure and column name in the second measure, please try to use the following measure:

 

Transactions **bleep** Prior Period =
IF (
    COUNTROWS ( 'Confirmed Transactions' ) > 0,
    CALCULATE (
        [Transactions **bleep** Current Period],
        SAMEPERIODLASTYEAR (
            FILTER ( ALLSELECTED ( Dates[Date] ), Dates[Date] <= MAX ( Dates[Date] ) )
        )
    )
)


Best regards,

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
amitchandak
Super User
Super User

Something like this. With date calendar

Cumm Sales = CALCULATE(SUM(Sales[Sales Amount]),filter(date,date[date] <=maxx(date,date[date])))

Cumm Sales = CALCULATE(SUM(Sales[Sales Amount]),filter(date,date[date] <=maxx(date,max(dateadd(date[date]),-1,year))))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thank you, I tried:

Transactions **bleep** Prior Period = CALCULATE(sum('Confirmed Transactions'[Transaction Count]),filter(Dates,Dates[Date] <= maxx(Dates,max(DATEADD(Dates[Date]),-1,YEAR))))
But i got a message that too few arguments were passed to Dateadd function.
 
Then i removed the close parenthesis after the last Dates[Date] and I got the message that the max function only accepts a column reference as an argument.
Greg_Deckler
Community Champion
Community Champion

Should be able to use PREVIOUSYEAR like:

 

Last year = CALCULATE([Transactions Cumulative Current Period],PREVIOUSYEAR('Dates'[Date]))

 

Also, if TI doesn't work See if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

If I use previous year as follows:

 

Transactions Cumulative Prior Period = CALCULATE([Transactions Cumulative Current Period],PREVIOUSYEAR(Dates[Date]))
 
I get a constant number that seems to be taking a sum of all transactions starting with a year ago from the beginning date in the slicer and ending with the ending date of the slicer. In the below example, the slicer runs from 3/1/2020 to 3/20/2020. It seems to be summing 3/1/2019 to 3/20/2020 to come up with a constant of 201453 for all days displayed.
 
 Capture.PNG
 
 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors