Supplies are limited. Contact info@espc.tech right away to save your spot before the conference sells out.
Get your discountScore big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount
Hi,
I am new to Power Query. I have written the following custom function for a query which I am trying to get to work:
(gsf as list, ltf as list, percentchange as list, grouping as list) as list =>
let
GSF = List.Buffer(gsf),
LTF = List.Buffer(ltf),
PercentChange = List.Buffer(percentchange),
Grouping = List.Buffer(grouping),
GRTList = List.Generate
(
()=> [ GRT = 0, i = 0, j = 0 ],
each [i] < List.Count(GSF),
each if j = 0
then if GSF{[i]} <> 0
then [GRT = GSF{[i]}, i = [i] + 1, j = [j] + 1]
else [GRT = LTF{[i]}, i = [i] + 1, j = [j] + 1]
else if GSF{[i]} <> 0
then [GRT = GSF{[i]}, i = [i] + 1, j = [j] + 1]
else try if Grouping{[i]} = Grouping{[i] + 1}
then [GRT = [GRT] * PercentChange{[i] + 1}, i = [i] + 1, j = [j] + 1]
else [GRT = GSF{[i]+1}, i = [i] + 1, j = 0]
otherwise [i = [i] + 1, j = 0]
,
each [GRT]
)
in
GRTList
But, I get the following error:
An error occurred in the ‘’ query. Expression.Error: The name 'j' wasn't recognized. Make sure it's spelled correctly.
Thanks a lot for the help!
Pankaj
Solved! Go to Solution.
Hey,
I found the mistake.
I found out that I was missing [] around j in the following statement:
each if j = 0
Br
Pankaj
Hey,
I found the mistake.
I found out that I was missing [] around j in the following statement:
each if j = 0
Br
Pankaj