Forum Discussion

guyinazo's avatar
guyinazo
Icon for Helper I rankHelper I
5 years ago
Solved

Stacked bar chart with rolling four weeks

Good morning all!  I know I need to create a measure for the last four week numbers and this is good as shown here: Rolling weeks =     VAR endweek = WEEKNUM)Today())    VAR startweek = endweek-4 ...
  • guyinazo's avatar
    5 years ago

    UPDATE:  For now I added a new column that is 

    Show On Visual = if(WEEKNUM('dataset'[Work Date])>WEEKNUM(Today())-4,1,0)

     

    Then I add this filter to the visual where the value is 1 and it works.

  • v-henryk-mstf's avatar
    5 years ago

    Hi guyinazo ,

     

    What result do you want to return for the measure you created. If you want to get the rolling value within four weeks, you can refer to the following formula.

     

    M =
    VAR endweek =
        WEEKNUM ( TODAY () )
    VAR startweek = endweek - 4
    RETURN
        CALCULATE (
            SUM ( 'Table'[Value] ),
            FILTER (
                ALL ( 'Table' ),
                WEEKNUM ( TODAY () ) >= startweek
                    && WEEKNUM ( TODAY () ) <= endweek
            )
        )

     

     


    If the problem is still not resolved, no further test can be done just by looking at the formula. Hope to provide a test data model (delete sensitive information) and detailed expected results.


    Best Regards,
    Henry


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