March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
I have sales data dating back 3 years. An input I use to determine upcoming sales is to look at upoming weeks sales from previous year. I would like to be able to look at 2019, 2018, 2017 sales history which is easy to do. The catch is I would like to be able to use todays date for 2019 and look at the next 2 to 4 weeks data in a table. I have a date table. I also have sales history by date for the past 3 years.
Today is 2/20/2020. I would like to be able to pull data from 2/20/2019 forward 2 weeks (or 4 weeks). As the current date changes I want to always be able to look at the forward looking data from a year ago. So tomorrow is 2/21/2020 so I would like to see the next 2 or 4 weeks from 2/21/2019.
I hope this makes sense.
Appreciate the help.
Hi @NSain1
Please try this as a measure. Replace The table and column names with the actual ones.
Sales in 4 Weeks LY =
VAR _4WeeksLY =
//current date + 28 days, go back to 12 months ago
EDATE ( MAX ( 'Fact'[Dates] ) + 28, -12 )
VAR TomorrowLY =
//current date + 1 day, go back to 12 months ago
EDATE ( MAX ( 'Fact'[Dates] ) + 1, -12 )
RETURN
//calculate sales for all the dates within _4WeeksLY and TomorrowLY
CALCULATE (
SUM ( 'Fact'[SalesAmount] ),
FILTER (
ALL ( 'Fact'[Dates] ),
'Fact'[Dates] >= TomorrowLY
&& 'Fact'[Dates] <= _4WeeksLY
)
)
Proud to be a Super User!
Thank you. I'll try it out and report back tomorrow.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
124 | |
86 | |
77 | |
57 | |
52 |
User | Count |
---|---|
201 | |
137 | |
108 | |
73 | |
68 |