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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
Elnaz91
Regular Visitor

For loop over rows comprising multiple columns

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 1column2column3new columnnew column formula
   00
1-1000-10000
0-100015001500max(0,max(0,0-1000)+1500)=1500
001001600max(0,max(0,1500+0)+100)=1600
0-1000-60540max(0,max(0,1600-1000)-60)=540
1-1000100010000
 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

2 REPLIES 2
edhans
Community Champion
Community Champion

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.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Thanks 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 1column2column3new columnnew column formula
   00
1-1000-10000
0-100015001500max(0,max(0,0-1000)+1500)=1500
001001600max(0,max(0,1500+0)+100)=1600
0-1000-60540max(0,max(0,1600-1000)-60)=540
1-1000100010000
 all values are <=0   

 

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors