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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Lurenz
New Member

How to filter two table with different dates

Hello, I've created a report with the forecast of sales, it works very fine, you can choose the period in the future and it shows all the data that we needed.

My boss asked me to put the amount of the sales of the last year of the same period of the forecast that you filtered.

I've imported in the data model the Sales table but i don't know how to do get the amount of the sales using the same filter of date of the forecast.

This is my model:

Lurenz_0-1603964786198.png

i tried the measure:

Sales Same period last year = CALCULATE(SUM(Sales_from_2019[vendita_totale]),SAMEPERIODLASTYEAR('Forecast cstm'[forecast_chiusura_prevista_c]))

and:

Sales Same period last year = CALCULATE(SUM(Sales_from_2019[vendita_totale]),SAMEPERIODLASTYEAR(DateCalendar[Date]))

but they don't work fine, the forecast's filtered data is not filtering the amount of sells of the last year

 

any ideas? Thanks

2 REPLIES 2
amitchandak
Super User
Super User

@Lurenz , you have date table you can use time intelligence

 

example - change based on need

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))
This year Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR('Date'[Date]),"12/31"))
Last year 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))
//Only year vs Year, not a level below

 

 

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 :radacad sqlbi My Video Series Appreciate your Kudos.

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

@amitchandak  Thank you for those measures, but i think i need something more specific because i need to compare not only year vs year but weeks, days or months.

 

Here an example:

I want to show all the forecast of sells from 29th of October 2020 to 29th of November 2020, and this is ok!

meanwhile i have to put the amount of the sells from 29th of October 2019 to 29th of November 2019, I don't find the right measure to calculate this amount using date filters that i used to show the forecast!

Thank you

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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