问题描述
我在excel中使用了幂查询,并且我使用了create custom列来创建一个新列,我迫切需要的是此新列从第二行中获取值并从第一行中减去它,然后再次对于所有行,都需要像这样进行:从第一行减去第二行,从第二行减去第三行,从第三行减去第四行。请帮忙。我不了解dax,也没有力量查询今天开始使用它,我只需要这一件事即可
I am using power query in excel and i used create custom column to create a new column, what i desperately need is for this new column to take the value from the second row and subtract it from the first row , and again this will need to happen for all rows like so: row two is subtracted from row one, and row three will be subtracted from row two and row four will be subtracted from row three. PLEASE help. I have no understanding of dax nor power query started using it today and i only need this one thing to work
PS。我有一个从一个索引开始,称为索引
,这里是代码
PS. I have an index that starts from one, called indexhere is the code
= Table.AddColumn(# Reordered Columns, Custom,每个[# ODO-Km]-[# ODO-Km])
= Table.AddColumn(#"Reordered Columns", "Custom", each [#"ODO - Km"] - [#"ODO - Km"])
这时,ODO km从同一行的ODO km中减去,我希望前一个odo km从下一个ODO km减去。
At this moment the ODO km is subtracting from the ODO km in the same row, I want the previous odo km to subtract from the next ODO km.
推荐答案
创建两个索引,一个基于0的索引,称为Index0 ,以及一个基于1的索引1。合并查询,使其自身与Index1 = Index0连接。现在,您将获得每列的重复项,但是它们将被偏移一。然后,您可以在一行中完成所有算术运算。之后,您可以删除所有想要的结果字段。
Create two indexes, one 0-based, called Index0, and one 1-based, called Index1. Merge the query with itself joining on Index1 = Index0. You'll now have duplicate of every column, but they will be offset by one. Then you can do all of your arithmetic in one row. After this, you can remove all but the result fields you want.
这篇关于功率查询从下面的行减去上面的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!