Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Barry_Sophus
Frequent Visitor

Calculation based on previous calculated value

I've been trying to create a column with a calculated value based on the previous calculated value but can't figure out how.

 

This is what I have so far:

var val = 1.5

var A = cos(val)*2

return A

 

Column AResult
=COS(1.5)*20.141474403335406
=COS(A1)*21.98001835431133
=COS(A2)*2-0.795791425329509
=COS(A3)*21.39943915409634
=COS(A4)*20.341039603168344
=COS(A5)*21.88481492380106
=COS(A6)*2-0.617766415528922
=COS(A7)*21.63034843303413
=COS(A8)*2-0.119033825371811
=COS(A9)*21.98584767068623
=COS(A10)*2-0.806473830974154
=COS(A11)*21.38409620019485
=COS(A12)*20.371234765893159
=COS(A13)*21.8637602491656
1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

Hi @Barry_Sophus 

This is difficult to handle with DAX, since DAX doesn't do recursion 😞

(This may seem silly because, in Excel, we can easily copy a formula and make use of relative references.)

With DAX, we could only produce these values in a calculated column if we could come up with a closed-form DAX expression, and as far as I can tell there is no such closed-form expression that produces terms solving the recurrence relation

 

a(n) = 2 * cos( a(n-1) )

 

but I would be happy to be proven wrong (see WolframAlpha ).

 

If this just needs to be a static column, you can instead use Power Query or some other process upstream to produce the values.

I have attached a small example using List.Generate in Power Query. This query relies on parameters StartingValue (1.5) and MaxIndex (14).

 

let
    #"Generate Values" = 
      List.Generate(
          ()=> [Index = 0, Value = StartingValue],
          each [Index] <= MaxIndex,
          each [Index = [Index]+1, Value = 2*Number.Cos([Value])]
      ),
    #"Convert to Table" = Table.FromRecords(#"Generate Values", type table[Index = Int64.Type, Value = number])
in
    #"Convert to Table"

 

Does this help?

 

Regards


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

View solution in original post

1 REPLY 1
OwenAuger
Super User
Super User

Hi @Barry_Sophus 

This is difficult to handle with DAX, since DAX doesn't do recursion 😞

(This may seem silly because, in Excel, we can easily copy a formula and make use of relative references.)

With DAX, we could only produce these values in a calculated column if we could come up with a closed-form DAX expression, and as far as I can tell there is no such closed-form expression that produces terms solving the recurrence relation

 

a(n) = 2 * cos( a(n-1) )

 

but I would be happy to be proven wrong (see WolframAlpha ).

 

If this just needs to be a static column, you can instead use Power Query or some other process upstream to produce the values.

I have attached a small example using List.Generate in Power Query. This query relies on parameters StartingValue (1.5) and MaxIndex (14).

 

let
    #"Generate Values" = 
      List.Generate(
          ()=> [Index = 0, Value = StartingValue],
          each [Index] <= MaxIndex,
          each [Index = [Index]+1, Value = 2*Number.Cos([Value])]
      ),
    #"Convert to Table" = Table.FromRecords(#"Generate Values", type table[Index = Int64.Type, Value = number])
in
    #"Convert to Table"

 

Does this help?

 

Regards


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.