Forum Discussion

Cookistador's avatar
Cookistador
Icon for Super User rankSuper User
1 year ago
Solved

Running Sum with Stacked Area chart ?

Hello Everyone,   I have to build a report and embedd this report on our company website So I discovered yesterday that publish to the web was not supported... I have to build a running sum, wi...
  • TomMartens's avatar
    1 year ago

    Hey Cookistador ,

     

    I suggest this measure that is more simple and probably a little faster:

    SalesAmount (running) = 
    var currentdDateKey = CALCULATE( MAX( 'DimDate'[Datekey] ) )
    return
    IF( NOT( ISBLANK( [SalesAmount (ms)] ) ),
        CALCULATE(
            [SalesAmount (ms)]
            , 'DimDate'[Datekey] <= currentdDateKey
        ),
        BLANK()
    )

    Of course, it's the same approach (i call this approach "sanity check"), checking if he current date (being pecised the max value based on the datekey granularity) has a value if not, do not create a running sum. This will avoid the "unnecessary calculations" while doing a "running something":

    But then, you have to be prepared that your chart will look like this:

    This happens because a line is not "projected" when there is no value. for this reason, you probably have to adapt the "sanity check" and the grain of your x-axis.

    Hopefully, this helps to tackle your challenge.

     

    Regards,

    Tom