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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anna_48
New Member

Use DAX to count products with 3 consecutive months of growth

I have a table 'Sales' with 3 main columns: ProductID, Date, Sales

I want to create a measure to count products with 3 consecutive months of growth. 

This measure below is correct?

 

ProductsWith ThreeMonthsGrowth =
VAR __MonthlySales =
    CALCULATE (
        SUM ( Sales[SalesAmount] ),
        DATESINPERIOD ( Sales[Date], MAX ( Sales[Date] ), -1, MONTH )
    )
VAR __PrevMonthSales =
    CALCULATE ( __MonthlySales, PREVIOUSMONTH ( Sales[Date] ) )
VAR __MonthlyGrowth =
    IF (
        NOT ( ISBLANK ( __PrevMonthSales ) )
            && __MonthlySales > __PrevMonthSales,
        1,
        0
    )
VAR __ThreeMonthsGrowth =
    CALCULATE (
        COUNTROWS ( FILTER ( Sales, __MonthlyGrowth = 1 ) ),
        DATESINPERIOD ( Sales[Date], MAX ( Sales[Date] ), -3, MONTH )
    )
RETURN
    CALCULATE (
        DISTINCTCOUNT ( Sales[ProductID] ),
        FILTER ( VALUES ( Sales[ProductID] ), __ThreeMonthsGrowth = 3 )
    )

 

1 ACCEPTED SOLUTION
Uzi2019
Super User
Super User

hi @Anna_48 

Rolling 3 Months:=CALCULATE(count[Total_Qty],DATESINPERIOD('Qty'[Month],LASTDATE(Qty[Month]),-3,MONTH))

 

and you can refer below blog for understanding:

https://community.fabric.microsoft.com/t5/Desktop/Monthly-Rolling-Year-Count/m-p/3643683#M1192662
https://community.fabric.microsoft.com/t5/Desktop/Cumulative-Total-of-a-Measure-for-last-3-months/m-...

https://community.fabric.microsoft.com/t5/Desktop/Cumulative-Count-by-Date/m-p/368918#M167100

https://community.fabric.microsoft.com/t5/Desktop/Rolling-Counts/m-p/2100913#M779672

 

you can modify the measure according your start date and end date.

 

I hope I answered your question!

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

View solution in original post

1 REPLY 1
Uzi2019
Super User
Super User

hi @Anna_48 

Rolling 3 Months:=CALCULATE(count[Total_Qty],DATESINPERIOD('Qty'[Month],LASTDATE(Qty[Month]),-3,MONTH))

 

and you can refer below blog for understanding:

https://community.fabric.microsoft.com/t5/Desktop/Monthly-Rolling-Year-Count/m-p/3643683#M1192662
https://community.fabric.microsoft.com/t5/Desktop/Cumulative-Total-of-a-Measure-for-last-3-months/m-...

https://community.fabric.microsoft.com/t5/Desktop/Cumulative-Count-by-Date/m-p/368918#M167100

https://community.fabric.microsoft.com/t5/Desktop/Rolling-Counts/m-p/2100913#M779672

 

you can modify the measure according your start date and end date.

 

I hope I answered your question!

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors