Forum Discussion
maico_presente
6 years agoRegular Visitor
Date Value from previous record
Hello, I've been working on a problem for hours and can't get any further! HELP ;-)) I have a list of users who belong to a group from a certain date. If a user is moved to another group i h...
- Anonymous6 years ago
You would need to add an index column in power query that allows you to look at the value from the previous row.
date_to = VAR currentindex = 'Table'[Index] VAR lastrowdate = CALCULATE ( MAX ( 'Table'[date_from] ), ALLEXCEPT ( 'Table', 'Table'[user_number] ), FILTER ( 'Table', 'Table'[Index] = currentindex + 1 ) ) RETURN IF ( [date_from] = CALCULATE ( MAX ( [date_from] ), ALLEXCEPT ( 'Table', 'Table'[user_number] ) ), TODAY (), lastrowdate - 1 )
Sample pbix: https://microsoftapc-my.sharepoint.com/:u:/g/personal/v-pazhen_microsoft_com/EUYxhep3tNpGk3Tinz6bPQQBCd2XSWMnxsAd6NjknWGdBQ?e=UZd1uX
Paul
Best
Anonymous
6 years agoNot applicable
Imke Feldmann has created a very useful function for shifting columns up and down:
The article above explains well how you can achieve your goal, but I will give a short summary. First, sort your table. Shift your date column with the mentioned function, the resulting column might be called date_from.Next. Then you can create a new column (like date_to = if date_from.Next = null then DateTime.LocalNow() else Date.AddDays(date_from.Next, -1)) that contains the data you want.