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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
DamianKelly
Frequent Visitor

Specific dates to extract from those available in dataflow, today and 7 days prior

Hi, I'm really hoping someone can help this Power BI novice! A colleague of mine kindly created a data-set, where one of the dataflows has +30days of data within it (so extracted daily, over 30 days). But he set it up to only pull the latest date on background refresh, i.e. today, so each morning the latest date is the only data extracted.

 

What I'd like to do is actually pull two dates from the +30 days available, so today's data and relative to that, seven days prior i.e. same day last week's data.

 


Found this for the -7

= Date.AddDays(Date.From(DateTime.LocalNow()), -7 ) 

This for the today

= Date.From(DateTime.LocalNow()) 

 

How do I combine? So I get both dates? 

DamianKelly_0-1697814942270.png

 

 

3 REPLIES 3
watkinnc
Super User
Super User

= Table.SelectRows(PriorStepOrTableName, each [Date] = Date.AddDays(Date.From(DateTime.LocalNow()), -7 ) or [Date] = Date.From(DateTime.LocalNow()))

 

--Nate


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!
DamianKelly
Frequent Visitor

Oh wow, that did it thank you so much!

 

Greg_Deckler
Super User
Super User

@DamianKelly Here is one way:

let
    Source = { Date.AddDays(Date.From(DateTime.LocalNow()), -7 ), Date.From(DateTime.LocalNow()) },
    #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error)
in
    #"Converted to Table"

@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors