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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
ChrisCollao
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:

AssetDatetimeEvent
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.

 

Example:

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.

2 REPLIES 2
Greg_Deckler
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
RETURN
    __Result

 


@ 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!:
Mastering Power BI 2nd Edition

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.

 

Thanks.

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.