Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

How to setup KPI for previous week and previous 2 weeks

Hello,   I have the following table from Excel and imported into Power BI. The ISO week number is calculated from the Date. I would like to have a KPI card that dynamically shows the previous week ...
  • v-jingzhang's avatar
    4 years ago

    Hi Anonymous 

     

    You can use these measures.

    Previous Week Total = 
    var _weekEnd = TODAY() - WEEKDAY(TODAY(),2)
    var _weekStart = _weekEnd - 6
    return
    CALCULATE(SUM('Table'[Submissions]),ALL('Table'),'Table'[Date]>=_weekStart,'Table'[Date]<=_weekEnd)
    Previous 2 Week Total = 
    var _weekEnd = TODAY() - WEEKDAY(TODAY(),2) - 7
    var _weekStart = _weekEnd - 6 - 7
    return
    CALCULATE(SUM('Table'[Submissions]),ALL('Table'),'Table'[Date]>=_weekStart,'Table'[Date]<=_weekEnd)

     

    I don't use the week number column. I calculate the week start date and week end date based on today's date directly in measures and use them to filter the table. My week is from Monday to Sunday. You can adjust the number substracted if needed. 

     

    Best Regards,
    Community Support Team _ Jing
    If this post helps, please Accept it as Solution to help other members find it.