Forum Discussion
Running Sum with Stacked Area chart ?
- 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
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