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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
avalerion
Frequent Visitor

Cumulative Count formula irrespective of dates

Having tried a few of the solutions posted around the web, I can't seem to figure out how to calculate a simple cumulative count.

 

In Excel, this would simply look like: =countif(A:A,"<="&date(2015,1,31)

The end result would provide a cumulative count as each month comes along.

 

However in my PowerBI model, there's a table with the 'account_creation_date' and another table acting as a master date table 'all_dates'. No relationship between the two since that would create some challenges.

 

So the question is how to create a formula that looks at ALL rows in the 'account' table and returns the cumulative count for that date where 'account_creation_date' = 'all_date'?

1 ACCEPTED SOLUTION
Twan
Advocate IV
Advocate IV

See if this works.  You just need to change the [Date] columns to the correct name of the date columns in your model.

 

Cumulative Count = CALCULATE(COUNTROWS('account_creation_date'), FILTER('account_creation_date', 'account_creation_date'[Date] <= MAX('all_dates'[Date])))

The equation would also have to change if you ended up creating a relationship between the 'account_creation_date' and 'all_dates' table.

View solution in original post

4 REPLIES 4
Twan
Advocate IV
Advocate IV

See if this works.  You just need to change the [Date] columns to the correct name of the date columns in your model.

 

Cumulative Count = CALCULATE(COUNTROWS('account_creation_date'), FILTER('account_creation_date', 'account_creation_date'[Date] <= MAX('all_dates'[Date])))

The equation would also have to change if you ended up creating a relationship between the 'account_creation_date' and 'all_dates' table.

Hi @Twan - I've also used this solution successfully, but please can you elaborate on how I'd need to change the measure if I have a relationship between the 'account_creation_date' and 'all_dates' table? I had a relationship which made some of my other visualisations work well, but stopped your formula working. If i deactivated the relationship, your formula worked well, but my other charts are now broken....

Many thanks.

If you have a relationship between 'account_creation_date'[Date] and 'all_dates'[Date] then the formula should look like the below equation.  Also, DAX Patterns has a good summary of how this type of measure works.

 

Cumulative Count =
CALCULATE( COUNTROWS('account_creation_date'),
    FILTER( ALL('all_dates'[Date]),
        'all_dates'[Date] <= MAX( 'all_dates'[Date] )
    )
)

 

That worked - thanks! I realized that there was another filter that I needed to append as well which solved the issue.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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