Forum Discussion
Problem with [Column Name] - [Column Name]{[Index]-1}
- 3 years ago
my bad, sorry
If your index column starts with 1 then use the following code:
if [Index] > 1 then [col2] - my_table[col2]{[Index] - 2} else nullIf your Index column starts with 0 then
if [Index] > 0 then [col2] - my_table[col2]{[Index] - 1} else null
I tried if [Index]>0 while starting the index with 1
it runs through, but everything is "0" again,
in addition 99% seems to be an error.
just for clarification
[Column Name] - #"my_table"[Column Name]{[Index]-1}
or is it
#"my_table" [Column Name] - #"my_table"[Column Name]{[Index]-1} ?
- AlienSx3 years agoSuper User
my bad, sorry
If your index column starts with 1 then use the following code:
if [Index] > 1 then [col2] - my_table[col2]{[Index] - 2} else nullIf your Index column starts with 0 then
if [Index] > 0 then [col2] - my_table[col2]{[Index] - 1} else null- MXSven3 years agoHelper I
thanks you very much
Why is it ?{[Index] - 2}- AlienSx3 years agoSuper User
Another example. Consider list of 2 items: {1000, 2000}:
List.Count({1000, 2000}) = 2
List.Positions({1000, 2000} = {0, 1}
1st item of the list: {1000, 2000}{0} = 1000
2nd item of the list: {1000, 2000}{1} = 2000
Hope you've got the idea.