Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
anisevance
Frequent Visitor

How to find out if X event happened when Y event was occuring

Hi all,

 

I have a problem for which I've been struggling to find a good solution in Power BI.

 

My department manages crisis response teams. Our teams receive 911 calls for service and then go out to those calls. Sometimes, our teams are already on a 911 call for service when another one comes in. We then "miss" this second call. 

 

Each row in our main database table includes fields for:

Unique Call ID number (auto-generated for each call)

Type of call (which lets us know if our teams are eligible for that call)

Day-Time of call

Unit Dispatched

Day-Time unit was dispatched

Day-Time call ended (i.e. when the unit leaves the scene and is available for another call)

 

It's easy enough to find out how many calls we missed because we can narrow down the Type of Call field to the calls for which we were eligible, and then subtract the eligible calls to which we were dispatched from the total eligible call volume.

 

What's not easy: ascertaining if the reason we missed a call was because we were on another call. We might miss calls because a unit is out of service for the day, is out of service for a critical meeting or some other important event, or our staff didn't hear the call come in (this last one is very rare, but it is theoretically conceivable). 

 

I'd like to know how, using the fields outlined above, I could find how many instances when we missed a call were due to us being on another call. Is this just a long IF/THEN statement, or is there a more elegant/efficient way to do this?

 

Thanks in advance!

 

5 REPLIES 5
tamerj1
Super User
Super User

Hi @anisevance 

Time related calculations  might be a bit heavy. I would recommend to first create a Day Unit Dispatched column (simply DATEVALUE ( 'Table'[Day-Time Unit Dispatched] ) 

the the flag column can be

Missed =
IF (
'Table'[Heart Eligible] = "Yes"
&& CONTAINSSTRING ( 'Table'[Unit Dispatched], "Police" ),
IF (
NOT ISEMPTY (
FILTER (
CALCULATETABLE ( 'Table', ALLEXCEPT ( 'Table', 'Table'[Day Unit Dispatched] ) ),
'Table'[Day-Time Unit Dispatched] <= EARLIER ( 'Table'[Day-Time Unit Ended] )
&& 'Table'[Day-Time Unit Ended] >= EARLIER ( 'Table'[Day-Time Unit Dispatched] )
&& 'Table'[Heart Eligible] = "Yes"
&& CONTAINSSTRING ( 'Table'[Unit Dispatched], "Heart" )
)
),
"Missed"
)
)

Despite this method is expected to be faster than directly filtering the complete table yet it may have a downside that you may lose track of some calles that occurred during midnight. Therefore you need to double check concerning on these records. 
sorry I didn't prepare a sample file to validate the results however, real data that need to be checked anyway. 

Thanks @tamerj1, this solution looks quite promising! I will try it and report back how it goes.

anisevance
Frequent Visitor

Thanks @FreemanZ! Below, please see a six line hypothetical sample of the data. We pull from a database, but all of the fields below are in the same table in that database. 

 

Our units are called HEART units. When we don't respond to a 911 call, police responds. So, you'll see HEART1, Police1, and Police2 in the Unit Dispatched field. 

 

What we would like to output: HEART missed one call for which we are eligible (call #2) because we were on another call (call #1) when call #2 came in (i.e. when a unit was dispatched). 

 

Unique IDTypeHeart EligibleUnit DispatchedDay-Time Unit DispatchedDay-Time Call Ended
1TRESPASSYesHeart11-1-2023 09001-1-2023 0930
2PANHANDLINGYesPolice11-1-2023 09151-1-2023 0940
3LARCENYNoPolice21-1-2023 09201-1-2023 1015
4MENTAL HEALTH CRISISYesHeart11-1-2023 10001-1-2023 1115
5TRAFFIC ACCIDENTNoPolice11-1-2023 10301-1-2023 1200
6SUICIDE THREATYesHeart11-1-2023 11301-1-2023 1300

 

FreemanZ
Super User
Super User

hi @anisevance 

the fields you mentioned in the database, are they from the same table? if not, how are they related?

 

It would be easier if you could provide some sample dataset with expected result.

Thanks @FreemanZ! Below, please see a six line hypothetical sample of the data. We pull from a database, but all of the fields below are in the same table in that database. 

 

Our units are called HEART units. When we don't respond to a 911 call, police responds. So, you'll see HEART1, Police1, and Police2 in the Unit Dispatched field. 

 

What we would like to output: HEART missed one call for which we are eligible (call #2) because we were on another call (call #1) when call #2 came in (i.e. when a unit was dispatched). 

 

Unique IDTypeHeart EligibleUnit DispatchedDay-Time Unit DispatchedDay-Time Call Ended
1TRESPASSYesHeart11-1-2023 09001-1-2023 0930
2PANHANDLINGYesPolice11-1-2023 09151-1-2023 0940
3LARCENYNoPolice21-1-2023 09201-1-2023 1015
4MENTAL HEALTH CRISISYesHeart11-1-2023 10001-1-2023 1115
5TRAFFIC ACCIDENTNoPolice11-1-2023 10301-1-2023 1200
6SUICIDE THREATYesHeart11-1-2023 11301-1-2023 1300

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.