Forum Discussion

RKK's avatar
RKK
Frequent Visitor
1 year ago

To populate current week data

Hi, 

 

I have a report with a page titled 'Assignment Details.' The report includes a week-wise slicer based on the week start date, along with a relative date filter to display only the data for the last 5 weeks. My goal is to have this week-wise slicer automatically select the current week whenever the report is opened, so that the data for the current week is displayed by default. I need this to update dynamically. Can anyone suggest a way to achieve this

4 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Thanks for the reply from johnt75  please allow me to provide another insight:

    Hi, RKK 

    The solutions proposed by johnt75 are excellent. If you find them helpful, please accept their responses as solutions. This will aid the development of our community and help other members with similar issues find solutions more quickly.

    Regarding your question, I have proposed two solutions:

    1.Firstly, you can directly use the relative date slicer:

     

    For further details, please refer to:

    Create a relative date slicer or filter in Power BI - Power BI | Microsoft Learn

    Here are the final results:

     

    2.Secondly, use measures to determine whether they have been filtered:

    Measure = 
    IF(ISFILTERED('Table'[week]),1,IF(WEEKNUM(MAX('Table'[Date]))=WEEKNUM(TODAY()),1,0))
    

    Then, apply them to the visualisation:

    Here are the final results:

    For further details, please refer to:

    ISFILTERED function (DAX) - DAX | Microsoft Learn

     

    You can choose between these two solutions based on your needs.

     

    Please find the attached pbix relevant to the case.

     

    Best Regards,

    Leroy Lu

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

  • RKK's avatar
    RKK
    Frequent Visitor

    Hi johnt75 and Anonymous 

    Thank you for your prompt reply. 

    In my case, the week starts on Thursday and ends on Wednesday, so my current week runs from November 28 to December 4. How can i use relative date for current week. Appreciate your help.

    • johnt75's avatar
      johnt75
      Super User

      Add a new column to your date table which checks if the date is within the current week. If it is then return "Current Week", otherwise return the value from whichever colum you are using on your week slicer. Hide this new column from the report view, and use it for the group by columns described in the post I linked to.