March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi. I have the following flight booking data. I'm looking for a Dax formula to pick out the actual destination. See below for what I'm looking for and some IF logic. RDU is the actual destination, the other rows are either connections or the flight back home from RDU.
LOOKING FOR.. | ||||||||
BookingNumber | departingAirport | arrivalAirport | arrivalTime | MaxArrival | ArrivalDate | Arrive/Connect | Actual Destination | |
12345 | BUF | ATL | 6/10/21 7:00 AM | 6/10/21 10:00 AM | 6/10/21 | Connection | N/A | |
12345 | ATL | RDU | 6/10/21 10:00 AM | 6/10/21 10:00 AM | 6/10/21 | Arrival | RDU | IF MaxArrival = arrivalTime AND Arrive/Connect = Arrival |
12345 | RDU | ATL | 6/14/21 11:00 AM | 6/14/21 2:00 PM | 6/14/21 | Connection | N/A | |
12345 | ATL | BUF | 6/14/21 2:00 PM | 6/14/21 2:00 PM | 6/14/21 | Arrival | N/A |
I'm thinking I need to find the minimum arrival date within the booking with the maximum arrival time/date to flag RDU as the destination.
MaxArrival is a caluclated measure:
Arrive/Connect is a calculated column:
Solved! Go to Solution.
@Dudeman
There are only a few more rows I can just type in. That was my mistake, I have thought about the multiple booking numbers, but forgot to bring it into the formula. Change the Result Destination measure to the following should work.
Best Regards
Paul Zheng _ Community Support Team
@Dudeman
There are only a few more rows I can just type in. That was my mistake, I have thought about the multiple booking numbers, but forgot to bring it into the formula. Change the Result Destination measure to the following should work.
Best Regards
Paul Zheng _ Community Support Team
Sorry Paul. One last question. That measure works, but I now need to composite in a country table with a relationship to the airport code. Result Destination needs to be in a calculated column in order for me to link the detination airport code to my country table (I think?).
Can you help with what the calculated column formula would be for the solution you provided?
Thanks again.
Amazing. Thank you SO much @V-pazhen-msft Paul. Really appreciate your help on this.
If it's not too much to ask, and no rush at all, would you mind explaining what the formula is doing? It's a bit difficult for me to understand all the pieces and how they're working together here.
Thanks again.
@Dudeman
To achieve your desired result, you would need to create the 3 measures:
MaxArrival = CALCULATE(MAX( 'Legs'[arrivalTime]),ALLEXCEPT ('Legs','Legs'[BookingNumber]),GROUPBY('Legs','Legs'[ArrivalDate]))
ArriveConnect = IF([MaxArrival]= MAX([arrivalTime]), "Arrival", "Connection")
Result Destination = IF([MaxArrival]=MINX(ALL(Legs),[MaxArrival]) && [ArriveConnect]="Arrival",MAX([arrivalAirport]))
Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.
@V-pazhen-msft Paul, thank you so much - very close but not quite. This is more what I'm looking for though.
This works with a single booking number, but when I apply it to my larger dataset with more booking numbers I only get a sinlge destination. I need to constrain the Min of the Max Arrival time to each booking number. How would you adjust your solution if there are more than one booking?
Thanks so much.
Here is an expanded example dataset.. for some reason it won't take my new table so here's an image of it:
12345 = RDU
23456 = YYZ
34567 = SEA
@Dudeman I would think a measure like:
Measure =
VAR __ArrivalAirport = MAX('Table'[ArrivalAirport]
VAR __ArriveConnect = MAX('Table'[Arrive/Connect])
VAR __ArriveDate = MAX('Table'[ArrivalDate])
RETURN
IF(__ArriveDate = [Max Arrival] && __ArriveConnect = "Arrival",__ArrivalAirport,"N/A")
Thanks for the reply Greg.
When I add your measure to the table a black box pops up and then disappears (with a title bar saying something about SQL) and then it breaks my table visual saying it can't display the visual.
Thoughts?
Perhaps there's another way to do this, a shorter way, where I don't need to use the Arrive/Connect calc'd column? Maybe I can say something like flag the row as the destination where the minimum MaxArrival date for a booking (6/10/21 10:00AM) equals the arrivalTime? Something like that could return RDU.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
124 | |
89 | |
84 | |
70 | |
51 |
User | Count |
---|---|
206 | |
143 | |
97 | |
79 | |
68 |