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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
gwhelan1
Regular Visitor

Flag for Last Value in a Set of Values

Hi All,

 

Hopefully this is a relatively easy ask, though for whatever reason I haven't been able to find a solution that meets my needs. I have some transportation data I'm working with, but the system feeding the data into my data model does not indicate which stop is the last stop on the shipment. What I need is some sort of indicator that stop X is the last stop for a given shipment; in the example below stop 5 is the last stop for shipment 200001.

 

Shipment_ID Stop_Number Planned_Arrival Planned_Departure Actual_Arrival Actual_Departure
200001 1 7/26/22 9:00 7/26/22 9:00 7/26/22 9:00 7/26/22 9:05
200001 2 7/26/22 9:30 7/26/22 9:40 7/26/22 9:30 7/26/22 9:40
200001 3 7/26/22 10:00 7/26/22 10:10 7/26/22 10:00 7/26/22 10:05
200001 4 7/26/22 10:30 7/26/22 10:35 7/26/22 10:35 7/26/22 10:40
200001 5 7/26/22 10:45 7/26/22 11:00 7/26/22 11:00 

 

Ultimately I'm trying to build a report to help identify how often the various freight carriers we use are not supplying the Actual_Departure date/time for the last stop on a shipment, but without some sort of identifier of which stop is the last stop (shipments can have a minimum of 2 or a max of 20 stops) I'm not sure how to even begin filtering for the correct calculation.

 

If there's a better way to do this without "flagging" the last stop per shipment, I'm open to it! Any help is appreciated!

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

You can check if the stop number in the current row equals the maximal stop number for that specific shipment.

 

For example, something like this as a new calculated column:

IsLastStop =
Table1[Stop_Number]
    = CALCULATE (
        MAX ( Table1[Stop_Number] ),
        ALLEXCEPT ( Table1, Table1[Shipment_ID] )
    )

 

View solution in original post

1 REPLY 1
AlexisOlson
Super User
Super User

You can check if the stop number in the current row equals the maximal stop number for that specific shipment.

 

For example, something like this as a new calculated column:

IsLastStop =
Table1[Stop_Number]
    = CALCULATE (
        MAX ( Table1[Stop_Number] ),
        ALLEXCEPT ( Table1, Table1[Shipment_ID] )
    )

 

Helpful resources

Announcements
Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.