Forum Discussion
Anonymous
5 years agoNot applicable
Calculating value differences for last 7 days for each element of the columns
Hi everyone! I wanted to ask for a help with a right way of constructing a loop inside the Power Query function. I have a table of date, index and multiple value columns like below with thous...
- 5 years ago
Hi Anonymous
You could try adding this using the Advanced Editor:
Data = Table.Buffer(Table.AddKey(LastStep, {"Index"}, true)),
AddLast = Table.AddColumn(Data, "Previous Day Diff",each let i = [Index] - 1 in Number.Abs( Data{[Index = i]}?[Value1]? - [Value1] )??0,type number ),AddLast7Check = Table.AddColumn(AddLast, "Last 7<5",each List.Max(List.Transform({[Index]-6..[Index]-1},(n) => AddLast{[Index = n]}?[Previous Day Diff]?) & {[Previous Day Diff]}) < 5,type logical)inAddLast7CheckReplacing LastStep with your last step's name.
Cheers
Smauro
5 years agoSolution Sage
Hi Anonymous
You could try adding this using the Advanced Editor:
Data = Table.Buffer(Table.AddKey(LastStep, {"Index"}, true)),
AddLast = Table.AddColumn(
Data, "Previous Day Diff",
each let i = [Index] - 1 in Number.Abs( Data{[Index = i]}?[Value1]? - [Value1] )??0,
type number ),
AddLast7Check = Table.AddColumn(
AddLast, "Last 7<5",
each List.Max(List.Transform({[Index]-6..[Index]-1},
(n) => AddLast{[Index = n]}?[Previous Day Diff]?) & {[Previous Day Diff]}) < 5,
type logical)
in
AddLast7Check
Replacing LastStep with your last step's name.
Cheers
- Anonymous5 years agoNot applicable
Smauro thank you very much, it worked!