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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
ReadTheIron
Helper III
Helper III

Count repeats in a time frame

I have two tables, one of failures, one of repairs, related on EquipmentName. I'm trying to find out if a given piece of equipment failed in the year after it was repaired.

RepairTable

EquipmentAreaEquipmentNameRepairDate
NorthSwitch11/1/2020
NorthSwitch22/1/2020
SouthSwitch33/1/2020
EastSwitch44/1/2020
SouthSwitch55/1/2020
SouthSwitch66/1/2020

 

FailureTable

EquipmentNameFailureDate
Switch16/1/2020
Switch48/1/2020
Switch21/1/2021
Switch15/1/2021
Switch38/1/2021

 

Whatever solution makes most sense - a measure, a calculated column - should let me filter visuals by whether a piece of equipment failed in the first year after repair. Examples might look like:

Problem Equipment
Switch1
Switch2

 

Or

EquipmentAreaFailed First Year
North2

 

I have a calculated column counting the total number of failures after the repair date, but I don't know how to add a time frame to that:

FailuresSinceRepair =
IF(ISBLANK(RepairTable[RepairDate),0,
COUNTX(
    FILTER(
        RELATEDTABLE(FailureTable),RepairTable[RepairDate]+1<=FailureTable[FailureDate]),FailureTable[FailureDate])+0)
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@ReadTheIron , New column in repair table

 

In next 1 year =

var _cnt = countx(filter(FailureTable, FailureTable[EquipmentName] =RepairTable[EquipmentName] && FailureTable[FailureDate] >=RepairTable[RepairDate] && FailureTable[FailureDate] <= RepairTable[RepairDate] +365) ,FailureTable[EquipmentName])

return

if(isblank(_cnt), "No", "Yes") 

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@ReadTheIron , New column in repair table

 

In next 1 year =

var _cnt = countx(filter(FailureTable, FailureTable[EquipmentName] =RepairTable[EquipmentName] && FailureTable[FailureDate] >=RepairTable[RepairDate] && FailureTable[FailureDate] <= RepairTable[RepairDate] +365) ,FailureTable[EquipmentName])

return

if(isblank(_cnt), "No", "Yes") 

Clear and elegant! Thank you!

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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