Forum Discussion

JamesBurke's avatar
JamesBurke
Helper III
2 years ago
Solved

Weekly Data

Hi all ,      I have the dashboard Above and i'm looking a filter of some sort that will show the Max week Usages on the Daily performance by default and when filtered by weekend will still ...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi,JamesBurke .
    Thank you for your detailed explanation and response.

    According to your description, you want to set the default value of the slicer to the previous week's data, when viewing the dashboard, if you don't manipulate the slicer, then visual will display the previous week's browsing history by default (dynamic filtering data).

    Solution1:

    You need to create two calculate columns

    1. Calculate the weekly number of weeks according to date.

     

    weekNum = WEEKNUM('Date'[Dates],2)

    2. If the data weekNum = WEEKNUM(today())-1, i.e., the week number of the data for the last week, it will be labeled as "LastWeek", and the rest of the data weekNum will be changed to “text” type.

    LastWeek = 
     IF([weekNum]=  WEEKNUM(TODAY())-1,"LastWeek",FORMAT([weekNum],""))
    

    Make the created calculate column "LastWeek" the default option for the slicer.


    Republish the report to the Power BI Service.
    like this:


    Solution2
    You can try using the ISFILTERED() function to determine if a field is currently being applied as a filter condition
    Here is my test case.(I created a new page to show it)



    IsSelected =
    IF(ISFILTERED('Date'[LastWeek]),SUM('Date'[dailyUsageNum]),
    CALCULATE(SUM('Date'[dailyUsageNum]),FILTER('Date','Date'[LastWeek]="LastWeek"))
    )


    I created a measure and put it into Visual's Y-axis to show: if the field [Last Week] is not being used as a filter at this time, it means that the slicer with [Last Week] as a filter field at this time is not selecting any value at this time, ISFILTERED('Date'[LastWeek])=false, and at this time, it is being used as a filter field with ' Date'[LastWeek]="LastWeek")) as a filter to display the results, that is, nothing to choose the case, the default display of the most recent week (the previous week) of data, otherwise that the slicer is selected, this time the normal use of the slicer value as a filter condition.

    Here is the test result:

    LastWeek =
    IF([weekNum]= WEEKNUM(TODAY())-1,"LastWeek",FORMAT([weekNum],""))

    I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.

    Best Regards,

    Carson Jian,

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