Forum Discussion

MP-iCONN's avatar
MP-iCONN
Icon for Resolver I rankResolver I
4 years ago
Solved

Show previous week in visual card

Not sure why I can't figure this one out as it seems very simple but I just want to have a visual card at the top of my page that will show the last weeks dates.  I have a table that is filtered by previous week dates via a sql query and I don't actually have any date fields in my data model for the data itself.  I do however have a DateTable setup with Start of week and End of Week dates.  Our week starts on a Monday and ends on Sunday.

 

Thank you for any help or advice you can give.

 

  • MP-iCONN , A measure like

    =

    var _st = today() +-1*WEEKDAY(today() ,2)+1 -7
    var _end = today() + 7-1*WEEKDAY(today(),2) -7

    return  _st & " to  " & _end

     

    Use format to format the date in the required format

4 Replies

  • MP-iCONN , You should create a week/date table with YearWeek (YYYYWW) , Then you can create week rank in week/date table and try measure like

     

    new column

    Week Rank = RANKX(all('Date'),'Date'[Year Week],,ASC,Dense) //YYYYWW format

     

    measures
    This Week = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])))
    Last Week = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])-1))

     

     

    If this does not help
    Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

    • MP-iCONN's avatar
      MP-iCONN
      Icon for Resolver I rankResolver I

      Lets say for example I just have a DateTable and no other Data.  My actual data is already filtered and showing everything I need in the table.  I however do not have any dates in that Data table.  I just want to show text in a card that represents the dates 02/07/22 - 02/13/22.  I am just trying to show in this report what dates are in last weeks Date Range so they know exactly what my data represents.

      For Example:

       

       

       

      • amitchandak's avatar
        amitchandak
        Icon for Super User rankSuper User

        MP-iCONN , A measure like

        =

        var _st = today() +-1*WEEKDAY(today() ,2)+1 -7
        var _end = today() + 7-1*WEEKDAY(today(),2) -7

        return  _st & " to  " & _end

         

        Use format to format the date in the required format