Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Filter dates as from previous ISO week (also valid when year change)

Hello,

I have the following data in a table visualization in Power BI. I am trying to filter the rows based on the Date column.

I am trying to filter all dates which are in the previous week and later.

The week is ISO, so it always starts on Monday and ends on Sunday.

The solution should also work for year change. For example, in ISO week number 1 for 2023, the filtered results should include the dates as from week number 52 in the previous year.

Is this possible? Any help is much appreciated!

 

DateStockReturnsDefective
08/08/2022348
01/01/20226917
27/05/20222510
20/10/20229316
07/08/20225615
12/08/20222210
17/08/20227822
20/08/20223313
22/08/20226318
29/08/20223314
07/09/20222717
16/09/20223722
23/11/20227520
11/12/20229818
04/01/20236716
17/02/202371434
  • 2 Comments

    1 - Your date dimension only goes up to the current date so showing future records would be tough.  Try extending it to the end of the current year or some other future date.

    2 - Since you already have [CurWeekOffset], the following column should work for you.

    Display = 'Calendar'[CurWeekOffset] >= -1
     
    I hope I understood you correctly.
     

5 Replies

  • Anonymous 

    is this what you want?

    Column =
    VAR yearweek=year('Date'[Date])*100+WEEKNUM('Date'[Date],2)
    return yearweek<year(today())*100+WEEKNUM(today(),2)
     
    when you select true , you will get all the date before this week.
    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi ryan_mayu Thank you for your reply!

      Here are the results from your formula but it is not quite right:

      We are currently in ISO week number 34, which started on Monday 22 August 2022.

      I would like to filter all the dates as from the previous week, that is, ISO week number 33 which started on Monday 15 August 2022.

      Here are the expected results (dates are sorted from oldest to newest):

      DateStockReturnsDefectiveFilter
      01/01/20226917FALSE
      27/05/20222510FALSE
      07/08/20225615FALSE
      08/08/2022348FALSE
      12/08/20222210FALSE
      17/08/20227822TRUE
      20/08/20223313TRUE
      22/08/20226318TRUE
      29/08/20223314TRUE
      07/09/20222717TRUE
      16/09/20223722TRUE
      20/10/20229316TRUE
      23/11/20227520TRUE
      11/12/20229818TRUE
      04/01/20236716TRUE
      17/02/202371434TRUE