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

Did you hear? There's a new SQL AI Developer certification (DP-800). Start preparing now and be one of the first to get certified. Register now

Reply
ligalbert
Helper I
Helper I

Consecutive months

I want to only show the customers ID of the customers who have done an order for 3 consecutive months. Is there a way I can create a measure for that 

fornula.PNG

2 REPLIES 2
tamerj1
Community Champion
Community Champion

Hi @ligalbert 
Here is a sample file with the solution https://we.tl/t-cA5KF3G3ii

1.png

RANK = 
RANKX ( 
    Orders,
    VAR CurrentDate = Orders[OrderDate]
    RETURN
        YEAR ( Orders[OrderDate] ) * 100 + MONTH ( Orders[OrderDate] ),,
        ASC,
        Dense
)

2.png

3.png

Filter Measure = 
VAR CurrentIDTable = CALCULATETABLE ( Orders, ALLEXCEPT ( Orders, Orders[ArCustomerID] ) )
RETURN
    SUMX ( 
        CurrentIDTable,
        VAR CurrentRank = Orders[Rank]
        VAR PreviousRanks = FILTER ( CurrentIDTable, Orders[RANK] >= CurrentRank )
        VAR Previous3Ranks = TOPN ( 3, CurrentIDTable, Orders[RANK], ASC )
        VAR Result = DIVIDE ( SUMX ( Previous3Ranks, Orders[RANK] ) - 3, 3 )
        RETURN
            IF (
                CurrentRank = Result,
                1
            )
    )
amitchandak
Super User
Super User

@ligalbert , Try a measure with help from date table

 

measure =
Var _1 = calculate(Countx(Values('Date'[MONTH Year]),CALCULATE(sum(Table[Order Count]))),DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-3,MONTH))
return
countx(Values(Table[AV CustomerID]) ,calculate( If( _1 =3, [AV CustomerID], blank())))

 


To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.