Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
guyinazo
Helper I
Helper I

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

RETURN

 

Here is my question though.  What am I returning?  A table of the two values that I can then apply to the stacked bar visual?

 

Thanks for the information

 

Brad

2 ACCEPTED SOLUTIONS
guyinazo
Helper I
Helper I

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.

View solution in original post

v-henryk-mstf
Community Support
Community Support

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
        )
    )

 

vhenrykmstf_0-1629267354906.png

 


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.

View solution in original post

2 REPLIES 2
v-henryk-mstf
Community Support
Community Support

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
        )
    )

 

vhenrykmstf_0-1629267354906.png

 


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.

guyinazo
Helper I
Helper I

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.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.