Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Input:
import pandas as pd
data = {
'Mes': list(range(1, 7)),
'Entrada': [892.78, 322.32, 557.25, 1034.96, 1641.06, 544.83],
'Saida': [997.81, 313.25, 734.94, 921.74, 859.57, 1142.17]
}
df = pd.DataFrame(data)
# Calculando o saldo
saldo = 0
saldo_list = []
for entrada, saida in zip(df['Entrada'], df['Saida']):
saldo = max(0, saldo + entrada - saida)
saldo_list.append(saldo)
df['Saldo'] = saldo_list
print(df)
output:
Mes | Entrada | Saida | Saldo |
1 | 892.78 | 997.81 | 0.00 |
2 | 322.32 | 313.25 | 9.07 |
3 | 557.25 | 734.94 | 0.00 |
4 | 1034.96 | 921.74 | 113.22 |
5 | 1641.06 | 859.57 | 894.71 |
6 | 544.83 | 1142.17 | 297.37 |
Hi @VilmarSch ,
Based on my testing, please try the following methods:
1.Create the simple table.
2.Create the measure to calculate saldo.
Saldo =
VAR sal = 0
VAR entra = CALCULATE(SUMX('Table', 'Table'[Entrada]))
VAR sasi = CALCULATE(SUMX('Table', 'Table'[Saida]))
RETURN
MAX(0, 0 + entra - sasi)
3.Drag the measure into the table visual, the result is shown below.
Best Regards,
Wisdom Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@v-jiewu-msftthanks for the answer, but it didn't give the expected result. I believe it is something more complex.
Hi @VilmarSch ,
May be you can try to use power query.
Solved: Do Not Consider If Accumulated Value Is Negative P... - Microsoft Fabric Community
Best Regardsd,
Wisdom Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
108 | |
88 | |
76 | |
66 |
User | Count |
---|---|
126 | |
112 | |
99 | |
82 | |
73 |