I’m trying to write a measure to be able to count when our staff have been double-booked.
The only solutions I’ve found online have involved adding a column to the main fact table which I can’t do (the production tables are Direct Query from an SQL DB).
Our primary transactions fact table has a row for every appointment with:
the provider name (“SCH_APPT_RESOURCE”),
a Date/time column for the appointment itself, and a column for each possible appointment state
(“IsCheckin”, “IsCancel”, “IsNoshow”)
(among others columns, not of interest here)
I figured I could created a virtual table with SUMMARIZECOLUMNS
and then use a filter to aggregate the sum of the “Checkins” virtual column, and count the number of times this was >1 (meaning there was more than 1 checkin for that resource, and that date/time), but this fails if I try adding a filter getting an error as I have to pass a scalar:
So if I wrap this in a SUM, the table evaluates:
So I figured I could wrap this expression in a COUNTROWS to find out the number of times there were double-bookings (or worse) but it’s throwing an error I don’t understand:
Note that it will evaluate if I place it on a visual by itself, but it fails if I try to add any other item to aggregate by (real data set has about 1M rows):
To try to figure this out, I created a ToyData set which has 1 double booking (10:00 AM, 5th January, 2023):
(and the PowerBI with the same measure now evaluates rather than throwing an error, but it’s telling me there are 3 “double-booking” rows (I think this should only evaluate to 2):
Weirdly, it will let me aggregate this by the Resource name, but not by the date field:
DuplicateAppts.pbix (40.2 KB)
ToyData.xlsx (8.9 KB)
I’m now lost as I can’t figure out:
- Why I am getting an error when I try to place this in a visual with some values, but not others?
- Why is the measure evaluating in the Toy data set report, but giving me 3 for the count of duplicates?
N.B. There’s the very real possibility this is completely the wrong approach to this problem, so if anyone has any other ideas, or is able to resolve what I’m doing wrong here, I’d be really grateful
Any help gratefully received,
Rod