Forum Discussion
Reference previous row to get value
- 9 years ago
I was able to get something to work by creating a Row ID using RANKX, and then another column (Prior Row ID) using EARLIER to get the previous Row ID. I then added this to my original Previous Odometer calculation as an additional filter:
Row ID := RANKX( ALL(Transactions[Transaction Date]), T ransactions[Transaction Date], , ASC, Dense)
Previous Row ID := CALCULATE
(
MAX(Transactions[Row ID]),
ALL(Transactions),Transactions[Vehicle #] = EARLIER(Transactions[Vehicle #]),
Transactions[Transaction Date] < EARLIER(Transactions[Transaction Date])
)
Previous Odoometer =
CALCULATE(MAX(Transactions[Odometer #]),
ALL(Transactions),
Transactions[Vehicle #] = EARLIER(Transactions[Vehicle #]),
Transactions[Transaction Date] < EARLIER(Transactions[Transaction Date]),
Transactions[Row ID] = EARLIER(Transactions[Previous Row ID]) )
)Curious to see if there is a much simpler way to achieve the same results....
Hey Diego - what is the reason as to why you are not able to create a calculated column? Are you connecting to a live cube? Could you create the calculated columns in the source?
Yes, I'm connected to the live cube(Power BI online?), my data is coming from a device( arduino) and I'm not sure about the calculated columns. I tried to create but I didn't get anything from the power BI online. Thank you for the reply.