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
JoyH
Helper I
Helper I

Cumulative Total: I want to take into account all prior dates to the selected date range

Sample File: https://drive.google.com/file/d/1IXufeou56iMyzzlXH7RBttoJug8daA8k/view?usp=sharing

I am trying to calculate the cumulative value using ALL previous dates but only DISPLAY the last 5 days.  

Current:

JoyH_2-1714418454711.png

Expectation:

JoyH_4-1714418598709.png

 

I have 3 tables trans, account, date

There is an active relationship on trans.date = date.date

There is an inactive relationship on account.accountcreateddate = date.date.

Account Count = CALCULATE(
                    COUNTROWS(Account),
                    USERELATIONSHIP(Account[AccountCreatedDate],DateTable[Date])
)

 

From 3/1/24 - 4/29/24 there was 1 account created per day.  

If I look at the running sum without any filters, the running sum of account count on 4/25 was 56

JoyH_0-1714418175605.png

But when I filter the page on DateTable.Date, the runningsum/cumulative count resets to only include that date range. The Transaction Amount is displaying correctly.

JoyH_1-1714418241724.png

Total Cumulative Amount =
    CALCULATE(
        [TotalAmount],
        FILTER(
            ALL('trans'),
            trans[date] <= MAX(trans[date])
        ))
 
What is the correct DAX for Total Cumulative Account Count?
1 ACCEPTED SOLUTION

Thanks @PhilipTreacy and @PhilipTreacy 

Hi, @JoyH 

Based on the example PBIX file you provided, I created the following DAX expression:

Total Cumulative Account Count1 = 
VAR _seleteddate =
    SELECTEDVALUE ( DateTable[Date] )
RETURN
    IF (
        ISINSCOPE ( DateTable[Date] ),
        COUNTAX (
            FILTER ( ALL('Account'), 'Account'[AccountCreatedDate] <= _seleteddate ),
            'Account'[account]
        ),
        COUNTA ( Account[account] )
    )

 Here are the results:

vjianpengmsft_0-1714629459218.png

vjianpengmsft_1-1714629776552.png

 

I've uploaded the PBIX file I used this time below.

 

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
PhilipTreacy
Super User
Super User

Hi @JoyH 

 

Download example PBIX file

 

If you have a Date table you should use an active relationship to it.  I deleted the relationship between trans and the Date table and made the relationship between the Date table and Account active.

 

I then wrote this

 

Measure = CALCULATE(COUNTROWS('Account'), FILTER(ALL('Account'), 'Account'[AccountCreatedDate] <= SELECTEDVALUE('Account'[AccountCreatedDate]) ))

 

You can then apply a Relative filter to the visual to only show the last X number of days 

 

reldates.png

 

Regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Thank you for taking the time to reply. 
I need to keep the relationship from trans to DateTable as the transaction date is what most of the report is about. The enduser wants to see the cumulative accounts active during the same date range.

 

You did give me another idea, however, and that is to count the accounts from the trans table and not the account. They will see the # of accounts that had transactions vs. # of accounts active, but it should be very close.

Thanks @PhilipTreacy and @PhilipTreacy 

Hi, @JoyH 

Based on the example PBIX file you provided, I created the following DAX expression:

Total Cumulative Account Count1 = 
VAR _seleteddate =
    SELECTEDVALUE ( DateTable[Date] )
RETURN
    IF (
        ISINSCOPE ( DateTable[Date] ),
        COUNTAX (
            FILTER ( ALL('Account'), 'Account'[AccountCreatedDate] <= _seleteddate ),
            'Account'[account]
        ),
        COUNTA ( Account[account] )
    )

 Here are the results:

vjianpengmsft_0-1714629459218.png

vjianpengmsft_1-1714629776552.png

 

I've uploaded the PBIX file I used this time below.

 

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

HotChilli
Super User
Super User

I think you want to use the Date dimension in the DAX:

Total Cumulative Account Count = 
    CALCULATE(
        [Account Count],
         DateTable[Date] <= MAX(DateTable[Date])
         )

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.