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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
MrMani
Frequent Visitor

3 in a row - consecutive monthly total greater than n value

Need a help on this measure to show each ID  - 3 in a row - consecutive monthly total greater than <n> value

find the below example data (summarized table with 3 columns)

Ex: n=15

for ID =1, 3 consecutive points aceived on Sep 23 (Consecutive months acheived on Jul, Aug,Sep 23)
for ID =2, 3 consecutive points aceived on May 23 (Consecutive months acheived on Mar, Apr, May 23)
Points is a monthly total points - measure; Calendar/Date table is mapped with this summary table 
every ID's starting month value varies

 

IDMonthPoints3 in a row
1Feb-2315 
1Mar-238 
1Apr-2316 
1May-2314 
1Jun-232 
1Jul-2318 
1Aug-2316 
1Sep-2320Y
1Oct-2323 
1Nov-2317 
1Dec-238 
1Jan-246 
2Aug-2212 
2Sep-2234 
2Oct-224 
2Nov-2245 
2Dec-222 
2Jan-2356 
2Feb-235 
2Mar-2320 
2Apr-2323 
2May-2317Y
2Jun-2328 
2Jul-236 

 

MrMani_0-1711421490079.png

 

1 ACCEPTED SOLUTION
vicky_
Super User
Super User

Try something like the below:

3 in a row = 
var prev = SUMX(WINDOW(0, REL, 2, REL, ADDCOLUMNS(ALLSELECTED('Table'[ID], 'Table'[Month], 'Table'[Points]), "> n value", INT('Table'[Points] > 15)), 
    ORDERBY('Table'[Month], DESC), 
    PARTITIONBY('Table'[ID])), [> n value]
)
RETURN IF(prev >= 3, "Y")

 

I'm pretty sure you can use a numeric slider to replace the N value = 15 if you need to make it dynamic.

And check out the docs for the window function: https://learn.microsoft.com/en-us/dax/window-function-dax

View solution in original post

2 REPLIES 2
vicky_
Super User
Super User

Try something like the below:

3 in a row = 
var prev = SUMX(WINDOW(0, REL, 2, REL, ADDCOLUMNS(ALLSELECTED('Table'[ID], 'Table'[Month], 'Table'[Points]), "> n value", INT('Table'[Points] > 15)), 
    ORDERBY('Table'[Month], DESC), 
    PARTITIONBY('Table'[ID])), [> n value]
)
RETURN IF(prev >= 3, "Y")

 

I'm pretty sure you can use a numeric slider to replace the N value = 15 if you need to make it dynamic.

And check out the docs for the window function: https://learn.microsoft.com/en-us/dax/window-function-dax

MrMani
Frequent Visitor

Thanks much Vicky.
Tried multiple flags with iterative functions, had performance hit.
But, this window function approach is upfront, and works like a charm:)

 

MrMani_1-1711462686731.png

 

 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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