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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
ninakarsa
Helper II
Helper II

selected filter date show day before and last

Hi All,

 

I would appreciate your help with the following calculations: I want to create a report with a date filter, and based on the date selected the following table A will be populated. Data in Table B

 

For example, i choose date 26/01/2019

the sales today =26/01/2019, sales yesterday=25/01/2019, sales same day last week=19/01/2019 and sales same day last year=27/01/2018

filter date26/01/2019

 

Table A:

ProductSales TodaySales yesterdaysame day last weeksame day last year
Product A660570390210
Product B129012001020840

 

Table B

ProductDateSales
Product A26/01/2018120
Product A27/01/2018210
Product A18/01/2019300
Product A19/01/2019390
Product A24/01/2019480
Product A25/01/2019570
Product A26/01/2019660
Product B26/01/2018750
Product B27/01/2018840
Product B18/01/2019930
Product B19/01/20191020
Product B24/01/20191110
Product B25/01/20191200
Product B26/01/20191290

 

 

 

 

3 REPLIES 3
v-easonf-msft
Community Support
Community Support

Hi , @ninakarsa 

Here we go.

1.Create a calculate table as   data slicer

Slicer = DISTINCT('Table B'[Date])

 

2.Then  try to use measure as below 

Sales Today = CALCULATE(SUM('Table B'[Sales]),FILTER('Table B','Table B'[Date] in FILTERS('Slicer'[Date])))
Sales yesterday = CALCULATE(SUM('Table B'[Sales]),FILTER('Table B','Table B'[Date] in DATEADD(FILTERS('Slicer'[Date]),-1,DAY)))
same day last week = CALCULATE(SUM('Table B'[Sales]),FILTER('Table B','Table B'[Date] in DATEADD(FILTERS(Slicer[Date]),-7,DAY )))

If you are sure that the  sales same day last year=27/01/2018 

same day last year = CALCULATE(SUM('Table B'[Sales]),FILTER('Table B','Table B'[Date] in DATEADD(FILTERS('Slicer'[Date]),-364,DAY)))

If   the  sales same day last year= 26/01/2018,then 

same day last year = CALCULATE(SUM('Table B'[Sales]),FILTER('Table B','Table B'[Date] in DATEADD(FILTERS('Slicer'[Date]),-1,Year)))

 

 

Here is a demo :

pbix 

 

13.png

 

 

Best Regards,
Community Support Team _ Eason

Greg_Deckler
Community Champion
Community Champion

OK, you should be able to create 4 measures for that. 

 

Sales Today = SUMX(FILTER('Table B',[Date] = TODAY(),[Sales])

Sales Yesterday = SUMX(FILTER('Table B',[Date] = (TODAY() - 1) * 1. ,[Sales])

 

Can you time intelligence for the other two or, 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...
amitchandak
Super User
Super User

Try with a date calendar

 

 today =CALCULATE(SUM(Sales[Sales Amount]))
 today =CALCULATE(SUM(Sales[Sales Amount]),'Date'[Date]=Today())
 today =CALCULATE(SUM(Sales[Sales Amount]),'Date'[Date])
 last day Sales = CALCULATE(SUM(Sales[Sales Amount]),(dateadd('Date'[Date],-1,DAY)))
 yesterday=CALCULATE(SUM(Sales[Sales Amount]),'Date'[Date]=Today()-1)
 same day last week Sales = CALCULATE(SUM(Sales[Sales Amount]),(dateadd('Date'[Date],-7,DAY)))
 same day last year Sales = CALCULATE(SUM(Sales[Sales Amount]),(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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.