Skip to main content
cancel
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

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
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.

July 2024 Power BI Update

Power BI Monthly Update - July 2024

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

July Newsletter

Fabric Community Update - July 2024

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