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
Anonymous
Not applicable

Checking status for three most recent dates per device

Hi all,

 

I am trying to create an indicator that will tell me if there's an issue with a device. "Issue" is defined as the status = failed for all three of the most recent entries per device.

 

My data looks something like this:

DeviceDateStatus
A8/1/2020Pass
A8/4/2020Fail
A8/6/2020Pass
A8/7/2020Fail
B8/10/2020Pass
B8/11/2020Fail
B8/14/2020Fail
C4/1/2020Pass
C5/1/2020Fail
C6/1/2020Fail
C7/1/2020Fail
D8/3/2020Fail
D8/7/2020Fail
D8/15/2020Fail

 

And I need an indicator per device (column or measure, either way) that will display the following:

DeviceIssue?
AFALSE
BFALSE
CTRUE
DTRUE

 

I need to look at each device, find the three most recent dates for that device, check the statuses on those dates, and if all three statuses are fail, indicate that there's an issue. The three most recent dates may be different for different devices.

 

Any ideas? I'm completely stumped right now and would appreciate any help!

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@Anonymous  - I think you could do it by creating a custom column like:

 

Rank = RANKX(FILTER('Table (2)', [Device] = EARLIER([Device])),[Date])

 

Then you could create a measure like:

Measure = 
    VAR __Table = SUMMARIZE(FILTER('Table (2)',[Rank]<=3),[Status])
RETURN
    IF(MINX(__Table,[Status])="Fail" && COUNTROWS(__Table)=1,"TRUE","FALSE")

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

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

Here's a solution using measures only.  You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Greg_Deckler
Super User
Super User

@Anonymous  - I think you could do it by creating a custom column like:

 

Rank = RANKX(FILTER('Table (2)', [Device] = EARLIER([Device])),[Date])

 

Then you could create a measure like:

Measure = 
    VAR __Table = SUMMARIZE(FILTER('Table (2)',[Rank]<=3),[Status])
RETURN
    IF(MINX(__Table,[Status])="Fail" && COUNTROWS(__Table)=1,"TRUE","FALSE")

@ 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...
Anonymous
Not applicable

Thank you, @Greg_Deckler! I knew there had to be a way to do this, I just couldn't figure it out.

 

P.S. I've been benefitting from the solutions you've provided here for the past few years, so thanks for all your indirect help too 🙂

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.