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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
1Kash
New Member

Query Last 100 Days for Past 3 Years

Greetings All,

 

I'm looking to set up a daily query that will pull the last 100 days from TODAY, for the current-year, prior-year and prior-prior-year periods.

 

The date ranges would look something like this from today's date December 7th:

 

PPYPYCY
12/7/202112/7/202212/7/2023
8/29/20218/29/20228/29/2023

 

I'm using Power Bi Desktop and have a daily scheduled refresh set-up

 

The code below is what I use to pull the last 100 days each morning, but not sure how to set up for the prior year periods.

= Table.SelectRows(#"Removed Columns", each Date.IsInPreviousNDays([close_date], 100))

 

Thanks in advance!

1 ACCEPTED SOLUTION
ThxAlot
Super User
Super User

Construct the periods by yourself (take 5 days for example)

let
    Source = let today=Date.From(DateTime.LocalNow()) in List.Accumulate({0..2}, {}, (s,c) => s & List.Dates(Date.AddYears(today, -c), 5, #duration(-1,0,0,0)))
in
    Source

ThxAlot_0-1702008033404.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LeanAndPractise(Everyday)


)



View solution in original post

2 REPLIES 2
ThxAlot
Super User
Super User

Construct the periods by yourself (take 5 days for example)

let
    Source = let today=Date.From(DateTime.LocalNow()) in List.Accumulate({0..2}, {}, (s,c) => s & List.Dates(Date.AddYears(today, -c), 5, #duration(-1,0,0,0)))
in
    Source

ThxAlot_0-1702008033404.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LeanAndPractise(Everyday)


)



This worked great. Thanks a lot, ThxAlot

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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