Forum Discussion
Distinct Count of Dates with Multiple Values - Part II
The reason you're getting the wrong count for "Non-Flight Days Away" is because of the way you've structured your DAX measure. The measure is counting days where the sum of 'Leg Hours' is 0, but it's not considering days that might also have 'Leg Hours' greater than 0. This is why you're seeing an overlap between "Flight Days Away" and "Non-Flight Days Away".
To ensure that a date is counted only once and that "Flight Days" take precedence, you need to modify the "Non-Flight Days Away" measure to exclude any days that are already counted in the "Flight Days Away" measure.
Here's a way to do it:
First, let's create a measure that gives us the distinct days where there was a flight:
Flight Days =
CALCULATETABLE(
VALUES('Appended Metrics'[Dept Date Local]),
'Appended Metrics'[Leg Hours] > 0,
'Appended Metrics'[Ver] = "-V-",
'Appended Metrics'[Local SAV Flights] = 0
)
Now, let's modify the "Non-Flight Days Away" measure to exclude the days from the above measure:
Non-Flight Days Away =
CALCULATE(
COUNTAX(
FILTER(
SUMMARIZE(
'Appended Metrics',
'Appended Metrics'[Dept Date Local],
"_1", SUM('Appended Metrics'[Leg Hours])
),
[_1] = 0
),
[Dept Date Local]
),
'Appended Metrics'[Ver] = "-V-",
'Appended Metrics'[Dept AP] <> "KSAV",
'Appended Metrics'[Arrive AP] <> "KSAV",
NOT('Appended Metrics'[Dept Date Local] IN Flight Days)
)
The key change here is the line NOT('Appended Metrics'[Dept Date Local] IN Flight Days). This ensures that any date that's already counted in "Flight Days Away" is excluded from "Non-Flight Days Away".
Regarding your confusion about the count being 2 versus 3: The measure you provided counts days where the sum of 'Leg Hours' is 0, but it doesn't consider days that might also have 'Leg Hours' greater than 0. So, for the date 9/21/2020, even though there's a flight with 1.6 hours, there's also a flight with 0 hours. Your measure counts this day as a "Non-Flight Day", which is why you're seeing the overlap.
By implementing the changes I've suggested, you should get the desired output:
Flight Days Away = 3
Non-Flight Days Away = 0