Forum Discussion

DharmaChinta's avatar
DharmaChinta
Frequent Visitor
7 years ago
Solved

Table visual to show only current week Data By default without any filter

Hi Team,

 

Is there a way to show only One week Data By default without any filter on a table visual and based on the week selection change accordingly ? May be a DAX that just filter on the current week ? I am new to power BI and need this functionality . Thanks in advance . Currently that table has 12 weeks of data by default .

  • Hi DharmaChinta,

    Try to create a measure like this


    Measure =
    CALCULATE (
    SUM ( Table[Column] );
    FILTER (
    ALL ( Table[DateColumn] );
    WEEKNUM ( Table[DateColumn] ) = WEEKNUM ( TODAY () )
    )
    )


    Regards,
    MFelix
  • Hi DharmaChinta,

     

    If you still want the slicers to work on it, you can try the measure below.

     

    Measure =
    VAR selectedWeek =
        SELECTEDVALUE ( 'calendar'[week] )
    RETURN
        IF (
            ISBLANK ( selectedWeek ),
            CALCULATE (
                SUM ( 'table'[value] ),
                FILTER ( calendar, WEEKNUM ( 'calendar'[date], 2 ) = WEEKNUM ( TODAY (), 2 ) )
            ),
            CALCULATE (
                SUM ( 'table'[value] ),
                FILTER ( calendar, WEEKNUM ( 'calendar'[date], 2 ) = selectedWeek )
            )
        )
    

     

    Best Regards,
    Dale

7 Replies

  • Hi DharmaChinta,

    Try to create a measure like this


    Measure =
    CALCULATE (
    SUM ( Table[Column] );
    FILTER (
    ALL ( Table[DateColumn] );
    WEEKNUM ( Table[DateColumn] ) = WEEKNUM ( TODAY () )
    )
    )


    Regards,
    MFelix
    • Anonymous's avatar
      Anonymous
      Not applicable

      Is this also possible for the current week and the current year? I have multiple years.

      • MFelix's avatar
        MFelix
        Super User

        Hi Anonymous 

         

        You need to add the year to the filter part of the measure:

         

        Measure =
        CALCULATE (
        SUM ( Table[Column] );
        FILTER (
        ALL ( Table[DateColumn] );
        WEEKNUM ( Table[DateColumn] ) = WEEKNUM ( TODAY () )
        &&
        YEAR ( Table[DateColumn] ) = YEAR ( TODAY () )
        )
        )
    • Anonymous's avatar
      Anonymous
      Not applicable

      To add also the current year:

      Measure = CALCULATE ( SUM ( Table[Column] ); FILTER ( ALL ( Table[DateColumn] ); WEEKNUM ( Table[DateColumn] ) = WEEKNUM ( TODAY () ) && YEAR ( Table[DateColumn] ) = YEAR ( TODAY () ) ) )

      Thanks a lot! 

      Sorry I deleted your answer by accident

      • brinky's avatar
        brinky
        Helper IV

        Is it possible have sales till yesterday instead till today?

  • v-jiascu-msft's avatar
    v-jiascu-msft
    Microsoft Employee

    Hi DharmaChinta,

     

    If you still want the slicers to work on it, you can try the measure below.

     

    Measure =
    VAR selectedWeek =
        SELECTEDVALUE ( 'calendar'[week] )
    RETURN
        IF (
            ISBLANK ( selectedWeek ),
            CALCULATE (
                SUM ( 'table'[value] ),
                FILTER ( calendar, WEEKNUM ( 'calendar'[date], 2 ) = WEEKNUM ( TODAY (), 2 ) )
            ),
            CALCULATE (
                SUM ( 'table'[value] ),
                FILTER ( calendar, WEEKNUM ( 'calendar'[date], 2 ) = selectedWeek )
            )
        )
    

     

    Best Regards,
    Dale