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
SergioTorrinha
Resolver II
Resolver II

Cumulative Count Not working as expected

Hi all,

 

My data model is composed , amongst other tables, by an Orders table (facOrder) and a dimensional customer table (dimCustomer).
These 2 tables are linked by customerID key.

 

I wrote a DAX metric to retreive the cumulative total of customers that had, at least one order registered in the facOrder table, like this:

CumUsers = 
// metric to calculate the cumulative number of customers since theyr first order


VAR CustomerOrders = 
                    SUMMARIZE(
                                facOrders,
                                facOrders[CustomerID],
                                "FirstOrderDate",
                                MIN(facOrders[CreationDate])
                            )

VAR SelDate =  MAX( dimDates[DateID] )

VAR CountCustomers = COUNTROWS( FILTER( CustomerOrders, [FirstOrderDate] <= SelDate  ) )
                    
RETURN

IF( CountCustomers  = BLANK(), 0 , CountCustomers  )

 

What's happening, is that this metric is not retreiving an acumulated total, but is, instead, calculating the total for a given selected (by the filter context) month. And, btw, I'm trying to plot a chart that renders monthly figures.

Before you ask for data: i'm working with sensitive data, so if you want something to test, please use  AdventureWorks database .

Thanks in advance 🙂

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@SergioTorrinha , Not very clear.

 

Try like

calculate(counrows(facOrders), filter(allselcted(facOrders) , facOrders[CreationDate] <=Max(facOrders[CreationDate])))

or

calculate(counrows(facOrders), filter(allselcted(facOrders) , facOrders[CreationDate] <=Max(facOrders[CreationDate]) && facOrders[CustomerID] <=Max(facOrders[CustomerID])))

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

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@SergioTorrinha , Not very clear.

 

Try like

calculate(counrows(facOrders), filter(allselcted(facOrders) , facOrders[CreationDate] <=Max(facOrders[CreationDate])))

or

calculate(counrows(facOrders), filter(allselcted(facOrders) , facOrders[CreationDate] <=Max(facOrders[CreationDate]) && facOrders[CustomerID] <=Max(facOrders[CustomerID])))

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

Hi @amitchandak !

Thank you for your feedback.
I managed to make it work properly, with the following adaptation of your first DAX:

a_test = 
        CALCULATE(
                DISTINCTCOUNT(facOrders[CustomerID]), 
                FILTER( ALLSELECTED(facOrders) , facOrders[CreationDate] <= Max(dimDates[DateID])) //Max(facOrders[CreationDate]))
                )


Thank you for your help! 🙂

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.