Forum Discussion
Calculate Recursively (?)
- 2 years ago
Hi konselz,
With the new rules it's better to solve task in Power Query I guess. If you want a clean solution, try asking gurus in the Power Query section of this forum.
The not-very-clean amateurish solution from me may look like this:
1) First, you go to Power Query and create an index column based on the Date column.
2) Then you create a function like this:
= ( i as number, a as number, b as number ) => let f = List.Generate( () => [j = 1, x = a, y = a - b], each [j] < i, each [y = [y] - 0.5*[x], x = [y], j = [j] + 1 ], each [y] ) in if (i = 1) then a else List.Last(f)3) Then you add a custom column like this:
= MyFunction ( [Index], List.Max(#"Changed Type"[ColA]), List.Max(#"Changed Type"[ColB]) )You will have ColA after that (ColB and ColC can be generated either via Power Query or via DAX):
Check the file here - https://www.dropbox.com/scl/fi/cjue59hlw4jrm8olxtoh9/community-no-recursion-2.pbix?rlkey=lt0bdlbolq97iqku0rtxz13s8&dl=0
Best Regards,
Alexander
Hi konselz,
With the new rules it's better to solve task in Power Query I guess. If you want a clean solution, try asking gurus in the Power Query section of this forum.
The not-very-clean amateurish solution from me may look like this:
1) First, you go to Power Query and create an index column based on the Date column.
2) Then you create a function like this:
= ( i as number, a as number, b as number ) =>
let
f = List.Generate(
() => [j = 1, x = a, y = a - b],
each [j] < i,
each [y = [y] - 0.5*[x],
x = [y],
j = [j] + 1 ],
each [y] )
in
if (i = 1) then a else List.Last(f)
3) Then you add a custom column like this:
= MyFunction ( [Index], List.Max(#"Changed Type"[ColA]), List.Max(#"Changed Type"[ColB]) )
You will have ColA after that (ColB and ColC can be generated either via Power Query or via DAX):
Check the file here - https://www.dropbox.com/scl/fi/cjue59hlw4jrm8olxtoh9/community-no-recursion-2.pbix?rlkey=lt0bdlbolq97iqku0rtxz13s8&dl=0
Best Regards,
Alexander