Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!
Hi,
I am trying to interate over rows and calculate this equation for my new column:
For every row:
if column1[i] = 1 then Newcolumn[i] =0
Else Newcolumn[i] = MAX(0, MAX(Newcolumn[i-1]+column2[i])+column3[i])
| column 1 | column2 | column3 | new column | new column formula |
| 0 | 0 | |||
| 1 | -1000 | -100 | 0 | 0 |
| 0 | -1000 | 1500 | 1500 | max(0,max(0,0-1000)+1500)=1500 |
| 0 | 0 | 100 | 1600 | max(0,max(0,1500+0)+100)=1600 |
| 0 | -1000 | -60 | 540 | max(0,max(0,1600-1000)-60)=540 |
| 1 | -1000 | 1000 | 1000 | 0 |
| all values are <=0 |
I tried to implement it with List.Accumulate, however, I have a problem calling three different columns in their expression. My main problem is the 2nd max function comprising the recursive term.
I also implement it as a recursive function but it never stops.
I hope one could help me! It's been more than a week and I am still struggling with it.
Thanks a lot
Elnaz
You are going to need to post some data so someone here can help.
How to get good help fast. Help us help you.
How To Ask A Technical Question If you Really Want An Answer
How to Get Your Question Answered Quickly - Give us a good and concise explanation
How to provide sample data in the Power BI Forum - Provide data in a table format per the link, or share an Excel/CSV file via OneDrive, Dropbox, etc.. Provide expected output using a screenshot of Excel or other image. Do not provide a screenshot of the source data. I cannot paste an image into Power BI tables.
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingThanks for the tip. The example is as follow:
For every row:
if column1[i] = 1 then Newcolumn[i] =0
Else Newcolumn[i] = MAX(0, MAX(Newcolumn[i-1]+column2[i])+column3[i])
| column 1 | column2 | column3 | new column | new column formula |
| 0 | 0 | |||
| 1 | -1000 | -100 | 0 | 0 |
| 0 | -1000 | 1500 | 1500 | max(0,max(0,0-1000)+1500)=1500 |
| 0 | 0 | 100 | 1600 | max(0,max(0,1500+0)+100)=1600 |
| 0 | -1000 | -60 | 540 | max(0,max(0,1600-1000)-60)=540 |
| 1 | -1000 | 1000 | 1000 | 0 |
| all values are <=0 |
The Power BI Data Visualization World Championships is back! It's time to submit your entry.
| User | Count |
|---|---|
| 20 | |
| 9 | |
| 8 | |
| 8 | |
| 7 |