The Preamble
I’m not sure we’ve adopted a universally recognised onomatopoeia for “the Teams tune”. Ring ring is obvs an old skool phone (remember those?) but “do do de do do woop woop” doesn’t really trigger the same imagery, does it?
I digress, and that won’t be the last time today. Now like any self-respecting autistic gen Xer, I hate the phone. And video calls. That Teams in-coming call notification triggers fight, flight, freeze or fawn every time. Teams does chat just fine, there’s no need for all that realtime social interaction thank you very much.
Oh yes, as I was saying, so my other favourite customer called. And I quite like talking to them so after declining the call, I sent them a meeting invite for 15 mins time. A neurodiverse brain thrives on planned events you know, none of these spontaneous unannounced calls.
The Oldest Latest Date
“I need to find the oldest latest date.”
Sometimes unpacking the requirement is the hardest part.
“The oldest latest date?”
“Yes, find the latest dates then the oldest”
“Ah, the min of all the maxes of each group?”
“Yes, the oldest latest”
Alexa, Write Me Some DAX
First up, some test data.
Here’s a list of courses, each course has a number of bookings. We’re looking for the most recent booking per course, and from that, the oldest date. In other words, the date of the last booking for course whose last booking is the oldest.
Or the date the longest inactive course last had a booking.
Test Data
|
|
Measures
First, a LastBookingPerCourse
measure. Why am I using REMOVEFILTERS
instead of ALLEXCEPT
? Because Marco knows DAX better than I ever will.
|
|
Next, to find the minimum over all courses (which could be filtered by some other table - region or category etc) using:
|
|
So simple pretty, once I’d recovered from do do de do do woop woop.
Just The Basic DAX
The DAX is also here