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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Selded
Helper III
Helper III

Distinct Count of Events

I need help with a logic / measure to distinctly count breakdown events in my data. snip 1 my data sample and snip 2 is expected results. 

i want a distinct count of downs based on ID. In the data attached, EO759 is contineously down from August 10-August 12th. Note that start and end is contineous. Example close for EO759 on 10th day shift is the start of EO759 on 10th night shift , hence is a single count. EO759 down from 10th to 12 will be counted as 1, because is the same down event that has taken a couple of days to get fixed.

 

EO759 is down again on August 14th. this breakdowns will be counted twice because there are seperate event based on the start and end time.

 

Selded_1-1599230441888.png

 

Expected results 

Selded_2-1599230460669.png

Thanks for the help.

 

7 REPLIES 7
Anonymous
Not applicable

 

 

// Here's how to do it in DAX.
// For each record (with the same ID) try to
// establish if there is another record where
// ID is the same and the start date equals
// the end date of the record in question.
// If there is one, then you've got a continuity,
// if there isn't, you've found the end of
// a continuity. Then you just count the number
// of discontinuities. Here's the
// implementation in DAX (but it would be much
// better to do it in PQ). T is your table as
// you've shown it.

[Expected Results] = // calculated table
groupby(
	ADDCOLUMNS(
		T,
		"@NextShiftDoesntExist",
			var __id = T[ID]
			var __end = T[End]
			return
				// If this is 1,
				// we've got a discontinuity.
				1 * ISEMPTY(
					FILTER(
						T,
						T[ID] = __id
						&&
						T[Start] = __end
					)
				)
	),
	T[ID],
	"Count", SUMX( CURRENTGROUP(), [@NextShiftDoesntExist] )
)

 

 

Please bear in mind that the End and Start fields should have the datetime data type. No text.

@Greg_Deckler 

Please i get this error when i use this dax.

 

Selded_0-1600158318633.png

Thanks 

@Selded The way you have that written it is returning a table. So you need to have that formula pasted in after selecting to create a new table.


@ 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...
Greg_Deckler
Super User
Super User

@Selded - See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/3395....
The basic pattern is:
Column = 
  VAR __Current = [Value]
  VAR __Previous = MAXX(FILTER('Table','Table'[Date] < EARLIER('Table'[Date])),[Value])
RETURN
  __Current - __Previous

 

I am pretty certain that you will need an Index and to create a "Continuous" column that returns 1 if it is continuous with the previous row.

 


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

@Greg_Deckler 

Please assist with how i can create an index and a contineous column that returns 1 for equipments on long term breakdown and also how i can calculate the MTTR. 

@Selded - Can you add an index column in Power Query? Sorry, can you provide an example of what you are looking for, not sure I have a clear understanding.


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

@Greg_Deckler 

 

I want to count contineous breakdowns as 1 as shown in my snips above .  The count for EO759 is 3 because the contineous downtimes even was counted as 1. 

 

i also need hep with a measure for the MTTR . 

 

Selded_0-1600082288123.pngSelded_1-1600082306182.png

 Thanks for the help

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors