Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Running Total Measure Works By Day but Not by Week

Hello,

 

I am having a problem with displaying the running total of a column in a Line and Stacked Column Chart visual.

This visual is to show forecasted and actual shipping numbers.

The X axis has the option of Fiscal Quarter, Fiscal Month, Fiscal Week, and Calendar Date.

When drilling down by Calendar Date, the running total works as expected. Green is forecasted shipping, and blue is actual. Red is the difference

 

But it only shows the sum for the given time period when drilling down any other way. (In other words, it's not cumulative.)

 

 

Here is the measure for the running total (Green Line):

 

CALCULATE(
    [Shipment Forecast],
    FILTER(
        ALLSELECTED('Fiscal Calendar'[Calendar Date]),
        ISONORAFTER('Fiscal Calendar'[Calendar Date], MAX('Fiscal Calendar'[Calendar Date]), DESC)
    )
)

Thanks in advance!
  • Anonymous's avatar
    Anonymous
    5 years ago

    Edited:

     

    [The Right Measure] =
    var MaxFiscalDate = MAX( 'Fiscal Calendar'[Calendar Date] )
    var Result =
    	CALCULATE(
    	    [Shipment Forecast],
    	    KEEPFILTERS( 'Fiscal Calendar'[Calendar Date] <= MaxFiscalDate ),
    	    ALLSELECTED( 'Fiscal Calendar' )
    	)
    return
    	Result

     

     

    There would be too much to explain about how ALLSELECTED works...

12 Replies

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

    Anonymous Not entirely certain but perhaps you need ALL not ALLSELECTED. Very hard to decipher what may be going on without something to play with.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Greg_Deckler This works as a running total, but I need this visual to not count anything before the selected period. So in filters from my example, nothing before Fiscal Q2 of 2021.

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

    Anonymous What happens if you base your running total on Fiscal Week instead of the Date?

    • Anonymous's avatar
      Anonymous
      Not applicable

      Greg_Deckler 
      I tried changing the running total measure to 

      OPs Ship Fcst running total in Fiscal Week =
      CALCULATE(
          [Shipment Forecast],
          FILTER(
              ALLSELECTED('Fiscal Calendar'[Fiscal Week]),
              ISONORAFTER('Fiscal Calendar'[Fiscal Week], MAX('Fiscal Calendar'[Fiscal Week]), DESC)
          )
      )

      But the visual looks the same. In addition when drilling down by calendar date, it no longer shows the running total.
  • Anonymous's avatar
    Anonymous
    Not applicable

    Edited:

     

    [The Right Measure] =
    var MaxFiscalDate = MAX( 'Fiscal Calendar'[Calendar Date] )
    var Result =
    	CALCULATE(
    	    [Shipment Forecast],
    	    KEEPFILTERS( 'Fiscal Calendar'[Calendar Date] <= MaxFiscalDate ),
    	    ALLSELECTED( 'Fiscal Calendar' )
    	)
    return
    	Result

     

     

    There would be too much to explain about how ALLSELECTED works...

    • Anonymous's avatar
      Anonymous
      Not applicable

      Anonymous 
      This does work as a running total, but I don't want it to count anything before the selected period. So in filters from my example, nothing before Fiscal Q2 of 2021.

      • Anonymous's avatar
        Anonymous
        Not applicable

        I've edited my measure... which now works as expected.