Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Create table by last 4 weeks

Hi 

 

I want to create a report that always shows the last 4 weeks data, grouped by that week. 

 

I have been trying to use a matrix table but I don't want the rows to group together.  I would like a table like below as my result set.  The sales stats come from a different data source than the days worked stats so I would be combining two or more queries.  

 

 2/12/20232/19/20232/26/20233/5/2023
Required Sales500655723800
Total sales120555700121
Sales Performance24%85%97%

15%

Days Worked454655

47

 

I can set a static visual that the dates are within the last 4 weeks so that next week the dates will change.  

 

Any help and guidance much appreciated

  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi Anonymous ,

     

    I think [Week] column in matrix column field should from a DimWeek table. I suggest you to try to create a measure to filter your visual.

    Filter = 
    VAR _THISWEEK =
        TODAY () - WEEKDAY ( TODAY () ) + 1
    VAR _Last4week = _THISWEEK - 28
    RETURN
        IF (
            MAX ( DimWeek[Date] ) >= _Last4week
                && MAX ( DimWeek[Date] ) < _THISWEEK,
            1,
            0
        )

    Add this measure into visual level filter and set it to show items when value = 1. Result is as below.

     

    Best Regards,
    Rico Zhou

     

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

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    I think [Week] column in matrix column field should from a DimWeek table. I suggest you to try to create a measure to filter your visual.

    Filter = 
    VAR _THISWEEK =
        TODAY () - WEEKDAY ( TODAY () ) + 1
    VAR _Last4week = _THISWEEK - 28
    RETURN
        IF (
            MAX ( DimWeek[Date] ) >= _Last4week
                && MAX ( DimWeek[Date] ) < _THISWEEK,
            1,
            0
        )

    Add this measure into visual level filter and set it to show items when value = 1. Result is as below.

     

    Best Regards,
    Rico Zhou

     

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