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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
MohanVanks
Helper II
Helper II

Calculate running count of months between two dates

Hello All,

 

I am trying to calculate the running count of months selected between two dates using relative date filter.

I have used below dax which gives me the running count of months between two dates 

MonthCount = 
 CALCULATE (
    
COUNTROWS(VALUES(VW_Supplier_Scorecard[yrmnth_nw])),
 FILTER (
 ALLSELECTED(VW_Supplier_Scorecard),  
 'VW_Supplier_Scorecard'[yrmnth_nw] <= MAX(VW_Supplier_Scorecard[yrmnth_nw])
 )
)

 

MohanVanks_0-1675063356545.png

But In my same report, i need to have month year filter as well where i could able to filter month wise.

Now when i filter from Year Month slicer,  then it is giving me only that month count.

But i am expecting the running count value should be returned.

MohanVanks_2-1675063491200.png

Here I have filtered Nov 22, it is returning 1, but i am expecting it to return as 15.

 

Can anyone help me please.

 

Thanks,

Mohan V.

 

 

 

5 REPLIES 5
MohanVanks
Helper II
Helper II

Can anyone please help me with this.

amitchandak
Super User
Super User

@MohanVanks , with help from date table

 

Cumm Sales = CALCULATE(SUM(Sales[Sales Amount]),filter(all('Date'),'Date'[date] <=max('Date'[date])))

 

Cumm Sales = CALCULATE(SUM(Sales[Sales Amount]),filter(allselected(date),date[date] <=max(date[Date])))

 

 

or window function

Power BI Window function Rolling, Cumulative/Running Total, WTD, MTD, QTD, YTD, FYTD: https://youtu.be/nxc_IWl-tTc

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

@amitchandak any help please

@amitchandak i tried the dax which you given using date master table, but it gives the running count of year-month column 

 

VAR minDate =
    CALCULATE (
        MIN ( 'DateMaster'[Date] ),
        ALLSELECTED( 'DateMaster' )
    )
RETURN
    CALCULATE (
        DISTINCTCOUNT(DateMaster[Year Month]),
        FILTER (
            ALL ( 'DateMaster' ),
            'DateMaster'[Date] >= minDate
                && 'DateMaster'[Date] <= MAX ( 'DateMaster'[Date] )
        )
    )

 

MohanVanks_1-1675075050327.png

 

But when i filter with Year month, then it gives the same result as above in my ask as 1.

MohanVanks_2-1675075091209.png

Can you please help me here.

 

Thanks,

Mohan V.

 

 

 

@amitchandak thanks for the reply.

In my case, i do not have any date table, and i shouldnt be using it for some reasons.

 

Can you please suggest/guide me for the same without date table.

Thanks,

Mohan V.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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