[英]Excel, Power Query: Pull columns from source workbook based on date
So this is a longshot, as I'm thinking it might be too complicated to explain an answer (if there is one) here.所以这是一个远景,因为我认为在这里解释答案(如果有的话)可能太复杂了。 But I'll give it a shot.
但我会试一试。 I track our client membership in a table like so:
我在一个表格中跟踪我们的客户成员资格,如下所示:
Columns A - G, has information like ID number, DOB, Phone, etc... stuff that doesn't change. A - G 列包含 ID 号、出生日期、电话等信息,这些信息不会改变。
Starting with H, each column represents a month (H is January, I is Feb, etc.).从 H 开始,每列代表一个月(H 是一月,I 是二月等)。 For each client, in each month I document if they are in the membership or not.
对于每个客户,我每个月都会记录他们是否在会员中。 So for example, the source wb looks like this:
例如,源 wb 看起来像这样:
ClientID![]() |
January![]() |
February![]() |
---|---|---|
100001 ![]() |
Yes![]() |
No![]() |
100002 ![]() |
Yes![]() |
Yes![]() |
Basically, I want to set up a query in another wb that pulls only the column that I want from the source wb based on today's date.基本上,我想在另一个 wb 中设置一个查询,该查询仅根据今天的日期从源 wb 中提取我想要的列。 I want my staff to have the mirror spreadsheet on their desktops and when they refresh, they get only the desired column.
我希望我的员工在他们的桌面上拥有镜像电子表格,当他们刷新时,他们只会获得所需的列。 Since it's a membership, it would have to be the previous month.
因为是会员,所以必须是上个月。 So when the current calendar month is February, and the staff refreshes, I want the excel to pull columns A - G (A only shown in the example) and also the January column, but not February.
因此,当当前日历月是二月并且员工刷新时,我希望 excel 拉列 A - G(仅在示例中显示 A)以及一月列,但不是二月。 Then when March comes along, again pull A - G, and February only (not Jan or any other months).
然后当三月来临时,再次拉 A - G,只拉二月(不是一月或任何其他月份)。 The point being to review if a member has cancelled (like in February in the example) and call the member.
重点是查看成员是否已取消(如示例中的二月)并致电该成员。
I've been able to setup a query with the full table.我已经能够使用完整表设置查询。 But I need it to filter out the undesired columns, and hopefully contingent on the current date.
但我需要它来过滤掉不需要的列,并希望取决于当前日期。
I get around pretty good on VBA, so I can program something.我在 VBA 上做得很好,所以我可以编程一些东西。 But I need help with this!
但我需要这方面的帮助!
Thank you谢谢
If data is loaded in PowerQuery, click select columns AG, then Transform.. Pivot Columns... Unpivot other columns...如果在 PowerQuery 中加载了数据,请单击 select 列 AG,然后单击转换.. Pivot 列...取消透视其他列...
Filter the results in the Attribute column to select the month you are looking for将 Attribute 列中的结果过滤为您要查找的月份的 select
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.