Forum Discussion
Power Query reference later added column
- 7 years ago
Just want to follow up on my previous post, rather than add ton of steps and still can't achieve the goal, at the end I just wrote a short python scripts using for loop and while loop then run it in Power Query Editor to add all columns I want.
Wasn't 100% clear to me, but here's what I got.
- Added a TRUE/FALSE column if the Max till Current Row - Current SOC > 0
- Added another column using List.Range and the Index column to get the previous column TRUE FALSE
- New Column for DeepCycle which looks for TRUE in the 1st column we added and then False in the second column
- New column that if Deep Cycle = 1 then give that Rows SOC value, otherwise null.
- Then filled down that column so the value of the SOC column when Deep Cycle was 1 is the value in the rows below it and not null
Also had to account if the index was 0 (since that was the 1st row)
Here's the final table. Made some changes to the Array SOC column so I could see if it was working like I expected. You wouldn't need all these columns and could really compress all these steps into just a few, or even better a function. But left them all there so you could see
PBIX file:
https://1drv.ms/u/s!Amqd8ArUSwDS0ywHNzHBP1ao--Eu
AnonymousHi Nick,
Thanks for your response, the idea is "Max till Current Row" should be reset to current SOC once there's a deep cycle achieved.
In your solution, it works since row 7 (SOC = 800) is bigger than row 2 (SOC = 700), but if I change the value of row 7 to 600, the deep cycle would not be detected.
There should be a deep cycle = 1 in row 8 since 600-66.17>70.
Thanks again.
- JeremyLeee7 years agoHelper I
Just want to follow up on my previous post, rather than add ton of steps and still can't achieve the goal, at the end I just wrote a short python scripts using for loop and while loop then run it in Power Query Editor to add all columns I want.