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
Car47
Frequent Visitor

Count records that meet a condition for sequential months

Hi all, I'm trying to identify rows in a given month that satisfy the same condition for 3 consecutive months. I've already created a new column in the table that calculates whether the conditino is met (1=yes, 0=no). What I ultimately want to end up with is a graph showing number of records that have met the condition in 3 consecutive months and I don't know how to structure it.  Example:

 

DeviceMonthCondition met
ABCSep 2020

1

BCDSep 2020

0

CDESep 2020

0

ABCOct 2020

1

BCDOct 2020

0

CDEOct 2020

1

ABCNov 2020

1

BCDNov 2020

0

CDENov 2020

0

 

This would calculate for that the most recent month only one Device met the condition for 3 consecutive months:

DeviceMonthCount
ABCNov 20201
BCDNov 20200
CDENov 20200

 

Can anyone help me calculate this, the result of which I want to graph by month. TIA!!

1 ACCEPTED SOLUTION

you need to replace
MaxDate = CALCULATE(MAX('Table'[Month]),ALLEXCEPT('Table','Table'[Device]))
to
MaxDate = MAX('Table'[Month])

View solution in original post

3 REPLIES 3
Ahmedx
Super User
Super User

Car47
Frequent Visitor

Ahmedx, thanks for the reply! This gets me almost there. It definitely let's me identify the number of devices that met the condition for 3 consecutive months in the most recent month (MaxDate). I would like to capture and graph that number(count) for each of the last x# months, not just the most recent. So I would want to calculate the number in 'flag fixed' in your example per month. Can you think of a way to do that? Thx.

 

you need to replace
MaxDate = CALCULATE(MAX('Table'[Month]),ALLEXCEPT('Table','Table'[Device]))
to
MaxDate = MAX('Table'[Month])

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.