Power Query Dynamic Date Filter With Intermittent Dates

ndbennett

New Member
Joined
Jul 14, 2017
Messages
17
I am creating a sales dashboard and I want to compare the last 7 days of available sales data against a weekly average.

My problem is that the timing of the availability of the sales data is not that reliable. At best it could be 3 days late but sometimes it is 5 or 6 days late. Therefore I would like to create a dynamic filter in Power Query to report only data from the most recently uploaded day plus the 6 days prior to that, regardless of the current date. Is this possible? Thanks!
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Hi, yes that's possible. You need to declare a variable.

Something like
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    SetTypes = Table.TransformColumnTypes(Source,{{"Dates", type date}, {"Value", type number}, {"Weeknum", Int64.Type}}),
    RefDate = Date.AddDays(List.Max(SetTypes[Dates]),-7),
    FilterSetOnRefDate = Table.SelectRows(SetTypes, each [Dates] > RefDate)
in
    FilterSetOnRefDate

Given this sample data
DatesValueWeeknum
7/05/2021$ 79,0918
9/06/2021$ 100,7823
17/05/2021$ 98,2820
26/05/2021$ 61,4121
31/10/2021$ 69,1743
4/07/2021$ 106,1426
12/07/2021$ 106,4628
23/09/2021$ 76,6338
31/10/2021$ 83,5343
13/08/2021$ 86,1632
20/09/2021$ 80,4838
31/08/2021$ 76,9635
2/05/2021$ 55,6417
21/10/2021$ 90,6842
29/09/2021$ 63,7339
20/10/2021$ 63,7042
17/06/2021$ 81,3324
19/07/2021$ 53,9829
25/10/2021$ 76,2843
17/10/2021$ 79,6041
8/05/2021$ 52,7218
10/10/2021$ 84,0640
20/07/2021$ 92,4129
1/11/2021$ 89,2144
5/10/2021$ 69,4340
4/05/2021$ 53,9818
4/11/2021$ 67,3344
24/06/2021$ 58,4325
4/10/2021$ 66,2740
14/09/2021$ 95,4137
22/07/2021$ 56,5329
22/05/2021$ 60,0520
20/08/2021$ 86,6133
13/05/2021$ 104,7919
10/05/2021$ 52,9919
24/07/2021$ 62,9929
28/10/2021$ 52,2843
11/08/2021$ 78,3032
20/09/2021$ 48,5538
18/09/2021$ 57,5537
12/09/2021$ 53,4236
23/10/2021$ 83,5342
6/07/2021$ 73,9027
16/10/2021$ 90,8641
28/06/2021$ 57,8826
2/05/2021$ 67,5517
24/10/2021$ 68,1642
3/08/2021$ 53,1231
23/07/2021$ 73,2929
27/07/2021$ 101,6130
28/06/2021$ 95,8326
28/07/2021$ 81,9030
18/08/2021$ 85,8733
15/09/2021$ 55,4037
27/05/2021$ 101,3421
21/09/2021$ 91,5638
25/09/2021$ 104,1738
10/08/2021$ 60,4932
6/05/2021$ 67,4118
12/10/2021$ 58,9141
28/07/2021$ 101,6330
15/05/2021$ 94,5319
17/09/2021$ 67,8437
29/05/2021$ 63,9421
25/10/2021$ 90,7643
27/09/2021$ 77,5439
1/08/2021$ 55,1730
1/10/2021$ 80,5939
7/09/2021$ 71,7236
22/09/2021$ 64,6438
26/07/2021$ 56,3430
13/07/2021$ 93,3028
15/06/2021$ 95,9724
18/08/2021$ 77,8033
8/08/2021$ 97,0031
6/06/2021$ 97,6122
16/08/2021$ 97,3533
4/05/2021$ 63,4718
24/06/2021$ 106,4825
21/06/2021$ 94,5525
17/06/2021$ 106,0524
20/09/2021$ 59,1338
14/07/2021$ 48,7028
4/07/2021$ 47,0326
28/10/2021$ 106,6743
5/07/2021$ 63,3427
26/07/2021$ 102,6930
1/11/2021$ 99,2844
27/05/2021$ 50,1021
26/09/2021$ 85,9038
18/07/2021$ 107,9828
17/08/2021$ 60,1433
11/06/2021$ 63,5423
9/06/2021$ 46,4123
28/06/2021$ 75,1526
17/09/2021$ 62,9137
5/09/2021$ 87,0435
1/10/2021$ 47,7139
25/06/2021$ 79,7525
21/09/2021$ 66,6038


this table is returned by the query
DatesValueWeeknum
31/10/2021$ 69,1743
31/10/2021$ 83,5343
1/11/2021$ 89,2144
4/11/2021$ 67,3344
1/11/2021$ 99,2844
 
Upvote 0
Solution
Great to read it's working. Thanks for this feedback.
 
Upvote 0

Forum statistics

Threads
1,215,440
Messages
6,124,882
Members
449,193
Latest member
PurplePlop

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top