具有重叠时间范围的时间序列,仅使用 Excel Power Query 中的最新数据 [英] Timeseries with overlapping timeframes, using just the most recent in Excel Power Query

查看:35
本文介绍了具有重叠时间范围的时间序列,仅使用 Excel Power Query 中的最新数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下问题:

在 Power Query 中,我可以使用 Power Query 将多个 csv 文件组合在一起,并具有从文件夹加载的功能.不幸的是,我们得到的时间序列数据是重叠的,整个时间序列的值都发生了变化.例如,我们每个星期一都会收到过去 30 天的文件.过去 30 天的值确实发生了变化,因此我上周报告中的值可能不再是最新的.我的目标是用本周的新数据覆盖上周的旧数据.

In Power Query i can bring together multiple csv files with power query, with the function to load from a folder. Unfortenatuly, the timeseries data we get is overlapping, with changed values for the entire timeseries. So for example we get a file for the last 30 days every monday. The values in the last 30 days do change, so the values from my report last week might not be up to date anymore. My goal is to overwrite the old data from last week with the new data from this week.

示例:

文件 A

Date        Item    Hits   Solved
01.01.2018  A       100    50
01.01.2018  B       138    65
02.01.2018  A       124    70
...
07.01.2018  A       143    50
07.01.2018  B       147    57
...
30.01.2018  A       250    124

文件 B

Date        Item    Hits   Solved
07.07.2018  A       143    80
07.07.2018  B       147    95
...
06.02.2018  A       341    148

文件 A 中的数据应使用文件 B 中的新信息进行更新,仅保留(在本例中)01.01.2018 到 06.01 的值.2018 来自 文件 A.其余的应该来自​​文件 B.

The data from file A should be updated with the new information from File B, keeping only the values from (in this case) the 01.01.2018 to the 06.01.2018 from file A. The rest should be from file B.

直到现在我试图给我的文件编号(越新越高,所以文件 A -> 1,文件 B -> 2),用日期+项目创建一个新的()列,按文件编号排序(后代),然后删除 key 列中的重复项.这有时有效(仅保留最近的条目),但有时不起作用.从 Date 列中删除重复项对我不起作用.在这里它只是删除最新的条目,保留旧的.

Until now i tried to give my files numbers (the newer the higher, so file A -> 1, file B -> 2), making a new (key) column with Date+Item, sorting (descendant) by file number and then removing duplicates in the key column. This sometimes works (only keeping the most recent entries), but sometimes it does not. Removing duplicates from the Date Column does not work for me. Here it just remove the newest entries, keeping the old.

有没有更好的方法来解决这个问题?

Is there a better way to solve this problem?

非常感谢!

推荐答案

转到根据文件顺序对数据进行排序的步骤,并将其放入 Table.Buffer() 中,因此它看起来像

Go the step where you are sorting the data based on your file order and put it inside Table.Buffer(), so it would look like

= Table.Buffer(Table.Sort(BLAH BLAH TABLE SORTING CODE))

我不记得技术原因,但出于此处的目的,这会重置 PQ 在运行删除重复项时使用的内部"排序顺序,以遵循表格的视觉排序顺序.

I don't remember the technical reasons, but for purposes here this resets the "internal" sort order PQ uses when running remove duplicates to follow the visual sort order of the table.

也没有必要创建一个关键列,您只需选择您的项目 + 日期列并删除重复项,它就会完成同样的事情.

Also it's not necessary to create a key column, you can just select your Item + Date Columns and remove duplicates and it will accomplish the same thing.

这篇关于具有重叠时间范围的时间序列,仅使用 Excel Power Query 中的最新数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆