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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Phoenix538
Frequent Visitor

Use selected filter for previous year

Good day all,

I am pretty new to Power Bi, loveing the program but stumbling accross something that I cannot figure out.

 

I sccuesfully managed to calculate the YTD turnover and compare it to the LYTD turnover. 

My report has a filter on year. So now I have 2020 selected and I want to see the comparison with previous year. 

I got it working with the LYTD using the following calculations:

 

Total Sales $ YTD = TOTALYTD(SUM(Turnover[turnover_sc]),'Date'[Date])
Total Sales $ LYTD = CALCULATE([Total Sales $ YTD], SAMEPERIODLASTYEAR('Date'[Date]))
 
But I also want to show the total turnover of previous year.
How can I calculate this? And How can i make a line diagram where the current year will continue in a straight line (I guess Running total)
But the turnover of previus year should be filled in for all months and not stop at April last year?
 
 
 
1 ACCEPTED SOLUTION
V-lianl-msft
Community Support
Community Support

Hi @Phoenix538 ,

 

You can try to create an unrelated calendar table to use as a slicer.

Running total:

Running total= 
CALCULATE (
    SUM ( Sales[Sales] ),
    FILTER (
        ALLSELECTED ( 'Sales' ),
       SELECTEDVALUE(DimDate[year])= YEAR(Sales[Date])&&
       Sales[Date]<=MAX(Sales[Date])
    )
)

Sum of last year:

sum_Sales_last_year = 
CALCULATE (
    SUM( Sales[Sales] ),
    FILTER (
        ALL ( Sales[Date] ),
        YEAR(Sales[Date]) = SELECTEDVALUE(DimDate[year])-1
     ))

Sample .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 @Phoenix538 ,

 

You can try to create an unrelated calendar table to use as a slicer.

Running total:

Running total= 
CALCULATE (
    SUM ( Sales[Sales] ),
    FILTER (
        ALLSELECTED ( 'Sales' ),
       SELECTEDVALUE(DimDate[year])= YEAR(Sales[Date])&&
       Sales[Date]<=MAX(Sales[Date])
    )
)

Sum of last year:

sum_Sales_last_year = 
CALCULATE (
    SUM( Sales[Sales] ),
    FILTER (
        ALL ( Sales[Date] ),
        YEAR(Sales[Date]) = SELECTEDVALUE(DimDate[year])-1
     ))

Sample .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.

Greg_Deckler
Community Champion
Community Champion

I think:
Turover LYTD = CALCULATE(TOTALYTD(SUM(Turnover[turnover_sc])), SAMEPERIODLASTYEAR('Date'[Date]))


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...

Hi @Greg ,

Thank you for the reply, but the LYTD i already have. However I am looking to have the total tunover of the year 2019 and not only to date. 

I tried with 

Total Sales $ LY = CALCULATE([Total Sales $ YTD], Filter(ALL('Date'), 'Date'[Year]=MAX('Date'[Year])-1), SAMEPERIODLASTYEAR('Date'[Date]))
 
However this will filter out the results of 2019 because it is filtered on the year 2020.
(Hope it makes a little sense)
 

@Phoenix538 , Try the complete one if you looking for the full year

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(('Date'[Date]),"12/31"))
This Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD((ENDOFYEAR('Date'[Date])),"12/31"))

Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))
Last YTD complete Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR(dateadd('Date'[Date],-1,Year)),"12/31"))
Last to last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-2,Year),"12/31"))

Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))
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

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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