Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Previous 5 Week and Future 5 Weeks

Hi Experts

 

I am trying to work out based on Date column in Table A - which items have been delivered in the Previous 5 week and which items are due to be delivered in the next 5 week. 

 

I have tried the following on Power Query

Date.IsInPreviousNWeeks([Date], 5) - This is not now giving correct results misses out week 48

 

and

 

Date.IsInNextNWeeks([Date], 5) - this is working

 

nor is the following working for previous 5 weeks

if Duration.Days(DateTime.Date(DateTime.LocalNow()) - [Date]) <= 30 then 1 else 0

 

Sample Data
https://www.dropbox.com/scl/fi/fp6fc17ssj27ts4zjvzsn/Test-Data.pbix?rlkey=yc98tuyh7wgvqx2mje4mzir4q&dl=0 

  • Ahmedx's avatar
    Ahmedx
    2 years ago

    pls try

    [
    t1 =Date.From( DateTime.LocalNow()),
    t2 = Date.StartOfWeek( t1),
    t3 = Date.EndOfWeek( t1),
    t4= Date.AddWeeks(t3,4),
    t5 = if [Date]>=t2 and [Date]<=t4 then true else false
    ][t5]

5 Replies