Sample sheet:
https://docs.google.com/spreadsheets/d/18zC42dPS_24YmzoNhHguMkTkX71RVaU91IaXf-zvnhs/edit?usp=sharing
样张:https://docs.google.com/spreadsheets/d/18zC42dPS_24YmzoNhHguMkTkX71RVaU91IaXf-zvnhs/edit?usp=sharing
I am trying to come up with formula either through Query or some other function to pull Data of past 4 weeks based on the week selected.
我正在尝试通过查询或其他一些函数来得出公式,以根据所选的一周来提取过去4周的数据。
For example in sheet 2, I have selected Week 8/28/2023, it shall pull data of that week and 3 weeks prior as highlighted in Sheet 2 from Sheet 1.
例如,在表2中,我选择了2023年8月28日这一周,它将从表1中提取表2中突出显示的该周和之前3周的数据。
QUERY doesn't seem to work as it will only have the Column specified in Select statement and I need to make it dymanic.
查询似乎不起作用,因为它将只有在Select语句中指定的列,我需要将其设置为动态的。
Tried with FILTER and was able to pull the values (Col L - O)
=FILTER(Sheet1!$A2:$AC2,Sheet1!$A$1:$AC$1<=$D$3)
已尝试使用筛选器,并能够提取值(列L-O)=筛选器(图纸1!$A2:$AC2,图纸1!$A$1:$AC$1<=$D$3)
But FILTER doesn't quite work rigth as I only want 4 weeks data to be pulled and as values get added it'll pull more than 4 weeks data.
但过滤器工作不太正确,因为我只想拉4周的数据,随着价值的增加,它将拉超过4周的数据。
更多回答
优秀答案推荐
If FILTER grabs the correct data, you can add a new statement to filter higher to that date -28:
如果筛选器捕获了正确的数据,则可以添加一个新语句以筛选到该日期-28:
=FILTER(Sheet1!$A2:$AC2,Sheet1!$A$1:$AC$1<=$D$3,Sheet1!$A$1:$AC$1>=($D$3-28))
I found another way around with Query by adding new transposed data and by adding start and end week. Although for this to work we will have to select week twice but I couldn't find any other easy way to do this xD
我找到了另一种处理查询的方法,添加了新的转置数据,并添加了开始和结束周。虽然要让它起作用,我们必须选择两次Week,但我找不到任何其他简单的方法来完成此xD
=TRANSPOSE(QUERY(Sheet3!1:1000,"SELECT A,B,C,D,E,F,G,H,I,J,K,L,M,N,O WHERE A IS NOT NULL AND A>=DATE """&TEXT(D3,"yyyy-MM-dd")&""" AND A<=DATE """&TEXT(D4,"yyyy-MM-dd")&""""))
更多回答
我是一名优秀的程序员,十分优秀!