cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

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
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors