Forum Discussion
leebaldwin
3 years agoHelper I
Pulling Data for A Week
Good afternoon: I have the following sql statement that I have written and it is pulling in data with no issue. My problem is that we want to have a full weeks of data. So, for this week (02/06 - 02...
- 3 years ago
what should happen when you run this on a sunday? Still the same rule ( ie take the previous sunday) ?
let Source = List.Dates(#date(2023,1,1),60,#duration(1,0,0,0)), #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error), #"Added Custom" = Table.AddColumn(#"Converted to Table", "Previous Sunday", each let d=Date.DayOfWeek([Column1]), p=if d=0 then 7 else d, r=[Column1]-#duration(p,0,0,0) in r) in #"Added Custom"How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done".
lbendlin
3 years agoSuper User
Do you need help determining the last sunday before "today" ?
- leebaldwin3 years agoHelper I
Yes sir, that is exactly what I need. Regardless of the weekday, it should pull the previous Sunday. Thank you.
- lbendlin3 years agoSuper User
what should happen when you run this on a sunday? Still the same rule ( ie take the previous sunday) ?
let Source = List.Dates(#date(2023,1,1),60,#duration(1,0,0,0)), #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error), #"Added Custom" = Table.AddColumn(#"Converted to Table", "Previous Sunday", each let d=Date.DayOfWeek([Column1]), p=if d=0 then 7 else d, r=[Column1]-#duration(p,0,0,0) in r) in #"Added Custom"How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done".
- leebaldwin3 years agoHelper I
lbendlin That is awesome. Definitely what I needed.