Forum Discussion

lmpb1988's avatar
lmpb1988
Frequent Visitor
2 years ago
Solved

Update week number automatically

Hi

 

In power bi I have a data segmentation visual based on the week number, which in turn takes the week number information from a calendar table.
The filter is working correctly but I would like to know if there is a way when I open the powerbi file that the week number can be updated automatically and not manually.
For example, I can set the filter between week 1 and week 52 (last week of the year) and all the data will appear, but I would like it to calculate the current week automatically and not have it inputted automatically. manually.

For example, at this moment, when I open the file I have, the filter is from week 1 to week 21, according to the image I added, and I can only change this if I do it manually.

 

Thanks

 

  • Apply the Filter to Your Visual:

    Go to the visual where you want to apply the filter.
    Drag the IsCurrentWeek measure to the Filters pane.
    Set the filter to show only items where IsCurrentWeek is TRUE.

4 Replies

  • lmpb1988 , For this you can create a measure first make sure you have a date table with week number

     

    Calendar =
    ADDCOLUMNS (
    CALENDAR (DATE(2023, 1, 1), DATE(2023, 12, 31)),
    "Year", YEAR([Date]),
    "Month", MONTH([Date]),
    "Week Number", WEEKNUM([Date], 2) -- 2 indicates that the week starts on Monday
    )

     

    Then create a new column in this date table to calculate current week

    CurrentWeek =
    IF (
    YEAR(TODAY()) = [Year],
    WEEKNUM(TODAY(), 2),
    BLANK()
    )

     

    Then create a measure for current week

    CurrentWeekMeasure = WEEKNUM(TODAY(), 2)

     

    Use this instead of Numweeked

    • bhanu_gautam's avatar
      bhanu_gautam
      Super User

      Apply the Filter to Your Visual:

      Go to the visual where you want to apply the filter.
      Drag the IsCurrentWeek measure to the Filters pane.
      Set the filter to show only items where IsCurrentWeek is TRUE.