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.
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 |
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 |
---|---|
102 | |
53 | |
21 | |
13 | |
11 |