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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
pedrocampos
New Member

Using previous row result

Dúvida.png

Hi

In this table presented below I have two columns, being: "Saldo_Inicial" and "Saldo_Final".

In the first row, the "Saldo_Final" column shows a value that was calculated from an initial value of 5000000 in the "Saldo_Inicial" column.
However, from the second line down I need the value shown in the "Saldo_Inicial" column to always be the calculated value in the "Saldo_Final" column of the previous line.

How do I do that?

2 ACCEPTED SOLUTIONS
camargos88
Community Champion
Community Champion

Hi @pedrocampos ,

 

You can create a recursive function to calculate all the "saldo_final" until the previous row like:

(_table as table, _saldo as number, _currentIndex as number, _index as number) as number =>
let
    Saldo = _saldo + (_table{_index}[Valor] + _table{_index}[Saldo Inicial]),
    Return = 
    if _index < _currentIndex - 1 then @Query1(_table, Saldo, _currentIndex, _index + 1)
    else Saldo
in 
    Return

Be aware with the function name, it need to be called inside the function as well.

 

Capture.PNG

 

Also, create a custom column to call the function.

Capture1.PNG



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



View solution in original post

Hello.

THank you very much.

Below, I post the solution that I wrote based on your post.

(_table as table, _saldo as number, _currentIndex as number, _index as number, _index_anterior as number) as number =>
let

Saldo = (_saldo * (1+(_table{_index_anterior}[Indexador_valor])))-((_saldo * (1+(_table{_index_anterior}[Indexador_valor])))/(_table{_index_anterior}[N_Parcela])) + _table{_index}[Saldo_Partida],

Return =
if _index < _currentIndex - 1 then @Saldo_inicial(_table, Saldo, _currentIndex, _index + 1,_index)
else Saldo
in
Return

 

View solution in original post

3 REPLIES 3
v-diye-msft
Community Support
Community Support

Hi @pedrocampos 

 

If you've fixed the issue on your own please kindly share your solution. if the above posts help, please kindly mark it as a solution to help others find it more quickly. If not, please kindly elaborate more. thanks!

 

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.
camargos88
Community Champion
Community Champion

Hi @pedrocampos ,

 

You can create a recursive function to calculate all the "saldo_final" until the previous row like:

(_table as table, _saldo as number, _currentIndex as number, _index as number) as number =>
let
    Saldo = _saldo + (_table{_index}[Valor] + _table{_index}[Saldo Inicial]),
    Return = 
    if _index < _currentIndex - 1 then @Query1(_table, Saldo, _currentIndex, _index + 1)
    else Saldo
in 
    Return

Be aware with the function name, it need to be called inside the function as well.

 

Capture.PNG

 

Also, create a custom column to call the function.

Capture1.PNG



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Hello.

THank you very much.

Below, I post the solution that I wrote based on your post.

(_table as table, _saldo as number, _currentIndex as number, _index as number, _index_anterior as number) as number =>
let

Saldo = (_saldo * (1+(_table{_index_anterior}[Indexador_valor])))-((_saldo * (1+(_table{_index_anterior}[Indexador_valor])))/(_table{_index_anterior}[N_Parcela])) + _table{_index}[Saldo_Partida],

Return =
if _index < _currentIndex - 1 then @Saldo_inicial(_table, Saldo, _currentIndex, _index + 1,_index)
else Saldo
in
Return

 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.