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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Frequent Visitor

Events Correlation

Hi all,


I'm trying to obtain a graph but I've couldn't find how to resolve it.


I have data from electronic failures of machinery. Basically, it's a table like this:

Asset 101-01-2023 12:30:00Engine Overspeed
Asset 202-01-2023 01:54:00Engine Oil Low Pressure
Asset 102-01-2023 17:12:00Transmission Abuse
Asset 102-01-2023 18:20:00Transmission Oil High Temperature
Asset 203-01-2023 16:34:00

Engine Overspeed

Asset 103-01-2023 16:35:00Engine Coolant High Temperature
Asset 203-01-2023 16:35:30Engine Coolant High Temperature


I want to count how many events happened at the same time or after each one of them by asset, in a certain window of time.


The goal of this is to obtain a matrix where I can see the correlation of events, where, by each event a certain amount of % of other event also happen in that window of time.



In the window of 24 hours, after one event of Engine Overspeed, it only occurs 0.5 events of Engine Coolant High Temperature. Why?

Because after the Engine Overspeed in Asset 1 seen at 01-01-2023 12:30:00, it doesn't happens anything else on the same asset within 24 hours, And, after the Engine Overspeed in Asset 2 seen at 03-01-2023 16:34:00, it only happens 1 event of Engine Coolant High Temperature in the same asset. So, by 2 events of Engine Overspeed, we can count 1 event of Engine Coolant High Temperature.


The resulting matrix in this example would look like this (for a time window of 24 hours): 

 Engine OverspeedEngine Oil Low PressureTransmission AbuseTransmission Oil High TemperatureEngine Coolant High Temperature
Engine Overspeed10000.5
Engine Oil Low Pressure01000
Transmission Abuse00111
Transmission Oil High Temperature00011
Engine Coolant High Temperature00001


I have no problem to vary the time window being declared as a variable inside the DAX function, but I don't know how to manage the time intelligence for the different assets.


Any idea?


Thanks a lot in advance.

Super User
Super User

@ChrisCollao This doesn't give the exact results in your matrix but you might be able to tweak the logic to get it the way you want. I'm probably missing something obvious. PBIX is attached below signature.

Measure = 
    VAR __Window = 1/24
    VAR __EventRow = MAX('Events'[Event])
    VAR __EventColumn = MAX('Table'[Event])
    VAR __Table = SELECTCOLUMNS(DISTINCT('Table'[Asset]), "__Asset", [Asset])
    VAR __Table1 = ADDCOLUMNS(__Table, "__RefDateTime", MAXX(FILTER('Table', [Asset] = [__Asset] && [Event] = __EventRow),[Datetime]))
    VAR __Table2 = ADDCOLUMNS(__Table1, "__EndDateTime", [__RefDateTime] + __Window)
    VAR __Table3 = ADDCOLUMNS(__Table2, "__Occurences", COUNTROWS(FILTER('Table', [Event] = __EventColumn && [Datetime] >= [__RefDateTime] && [Datetime] <= [__EndDateTime])))
    VAR __Count = COUNTROWS(__Table3)
    VAR __Occurences = SUMX(__Table3, [__Occurences])
    VAR __Result = DIVIDE(__Occurences, __Count) + 0


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler , thanks for your answer,


I've being trying with your proposition but I couldn't obtain the right values 😞 I don't know if it's not properly counting through time window or assets. Will keep trying anyway.



Helpful resources

July 2024 Power BI Update

Power BI Monthly Update - July 2024

Check out the July 2024 Power BI update to learn about new features.

July Newsletter

Fabric Community Update - July 2024

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