Skip to main content
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

New Member

Creating an IF statement using the previous cell as reference to keep track of different departures

I'm currently working with a dataset of bus stops. The data doesn't indicate which specific trip each one belongs to, but it does indicate the license plate of the bus in question, which is my only bet for sorting them out (which I do need to do as part of the job). The problem is these being buses they of course show up multiple times during each day because they aren't doing a single trip, they do a few.


Their data is clustered by trips and as far as I could tell the same bus doesn't have its trips stored next to one another, so I thought of doing it this way: I make a new column with an If statement that checks the cell just before it. If it's the same plate then copy the last value used. If it's different then add 1 to the same value


Something like this


RouteDescriptionPLATEDirectionStopTimestampPeople inPeople outNEW COLUMN






That way I can then merge the new column with the plate and I would be able to know for certain which data belongs to which specific trip


That's the general idea I have but I don't know what the syntax would have to be or even if it is possible at all

Community Support
Community Support

Hi @NotMe ,


Don't seem to understand your requirements, can you explain the relationship between the PLATE, DIRECTION and ROUTE fields and the desired screenshot of the results?

Looking forward to your reply.

Best Regards,


Plate is the license plate for the bus.


Direction is which way the bus is going. Either from point a A to point B or from point B to point A. There are busses that do multiple trips of each direction which is why I can't just use that so sepparate them.


Route you can ignore since I'm only working with the data from one specific route, meaning it's the same in every entry. Same with Description.


Also another caveat is that the busses don't all make the same stops each trip. They change depending on where people need to board or get off. They are also string data with no clear indication as to the order they're in. There is a timestamp on each entry though that I just realized I accidentally left out in the table earlier.

Helpful resources

Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.


Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

Top Solution Authors