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

Be 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

Reply
NSain1
Frequent Visitor

Attempting to create data pull for number of rolling days using today's date but for previous years

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.  

3 REPLIES 3
danextian
Super User
Super User

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

 










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Thank you.  I'll try it out and report back tomorrow.  

Hi @NSain1 ,

 

Is your problem solved? 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.