Forum Discussion

KrisD's avatar
KrisD
Icon for Helper II rankHelper II
4 years ago

Cumulative total for previous week does not work even though standard pattern is used

Hi!

 

I can't seem to get the rolling total to work, even though I (at least I think I do) have used the variations of cumulative patterns from SQL BI guys, Chandeep and Enterprise DNA. Obviously there's something I'm missing here!

I get the date range as expected, but none of the patterns I have tried work. What's missing?

 

10 Replies

  • ValtteriN's avatar
    ValtteriN
    Icon for Community Champion rankCommunity Champion

    Hej,

    For running total in a column the dax is a bit different. Try something like this:

    RT =
    CALCULATE(Sum(Cumulativetotal[Value]),

    ALL('Cumulativetotal'),Cumulativetotal[Date]<=EARLIER(Cumulativetotal[Date]))
     

    I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

    • KrisD's avatar
      KrisD
      Icon for Helper II rankHelper II

      Hi and thanks for the swift reply!

      Actually it's not supposed to be calculated as a column in this context, I made the table in DAX Studio in order to troubleshoot. The calculation is intended for a visual as per below picture, where I either get the total for all the rows, or only on row by row context. But no cumulative I'm afraid. 

       

       

      • ValtteriN's avatar
        ValtteriN
        Icon for Community Champion rankCommunity Champion

        I see, in that case you could try removing the FILTER() in your CALCULATE. Now the FILTER filters a table where dates are smaller than the max date -> so all the dates and then it performs SUM operation -> SUM of all. This is the cause for your error. Referring to the SQLBI's example: https://www.sqlbi.com/articles/computing-running-totals-in-dax/

        Sales RT :=
        VAR MaxDate = MAX ( 'Date'[Date] ) -- Saves the last visible date
        RETURN
            CALCULATE (
                [Sales Amount],           -- Computes sales amount
                'Date'[Date] <= MaxDate,  -- Where date is before the last visible date
                ALL ( Date )              -- Removes any other filters from Date
            )
         
        The example syntax doesn't have FILTER because of this reason.



  • Hi KrisD 

     

    Check this link:

    https://www.vahiddm.com/post/weekly-time-intelligence-dax 

     

    Hi

     

    Can you post sample data as text and expected output?
    Not enough information to go on;

    please see this post regarding How to Get Your Question Answered Quickly:
    https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

    The most important parts are:
    1. Sample data as text, use the table tool in the editing bar
    2. Expected output from sample data
    3. Explanation in words of how to get from 1. to 2.
    4. Relation between your tables

    Appreciate your Kudos!!
    LinkedIn:www.linkedin.com/in/vahid-dm/

     

     

    • KrisD's avatar
      KrisD
      Icon for Helper II rankHelper II

      Hi, I've created a sample file with data, measures and desired result. --> https://easyupload.io/1okeq9

      I got the WTD to work, I'm having issues with Previous month instead, which is defined in the file.