Forum Discussion

HEW's avatar
HEW
Helper III
4 years ago
Solved

Show last 4 weeks in Matrix

Hi.   I would like to show a matrix, where values for only the last 4 weeks are shown. Now it is week 1, so I would like to see data for week 49-52. How do I solve this? Thanks a lot.
  • v-kkf-msft's avatar
    v-kkf-msft
    4 years ago

    Hi HEW ,

     

    Please try the following formula:

     

    Measure = 
    var CurWeekDay = WEEKDAY(TODAY(), 2)
    var DateEnd = TODAY() - CurWeekDay
    var DateStart = DateEnd - 7 * 4 + 1
    return 
        CALCULATE( 
            SUM('Table'[Value]) ,
            FILTER(
                Dates,
                Dates[Date] >= DateStart 
                    && Dates[Date] <= DateEnd
            )
        )

     

    If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
    Best Regards,
    Winniz
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.