Forum Discussion
conwayzerbeam
3 years agoNew Member
Custom Column Formula Syntax
Hello all, So I am attempting to create a custom column to accomodate a certain situation and I for the life of me can't figure it out. I'm relatively new to PowerBi/Query so still working throug...
conwayzerbeam
3 years agoNew Member
Judging by your pictures, I think that is mostly what I want.
Where would I input that code though? Here?
Payeras_BI
Solution Sage
3 years agoHi conwayzerbeam,
Yes, paste below code there but before substitute in the code all appearances of YourPreviousStep and [MeterReading] with the ones that correspond (see the screenshot for your reference).
(row) =>
let
currentRow = Table.PositionOf(YourPreviousStep, row),
currentMeterReading = row[MeterReading],
result = List.Accumulate({0..currentRow}, 0, (state, index) =>
let
prevRow = index - 1,
prevMeterReading = if prevRow >= 0 then YourPreviousStep{prevRow}[MeterReading] else null,
currMeterReading = YourPreviousStep{index}[MeterReading]
in
if prevMeterReading <> null and currMeterReading < prevMeterReading then state + 10000000 else state
)
in
result + currentMeterReading