Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Relative Date Slicer

Hi,    I have a report with a relative date slicer using date column. Slicing is always done from today onwards.   This slicer filters a matrix which reports on weekly basis using week ending dat...
  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi Anonymous ,

    I created a sample pbix file(see attachment) base on your provided data, please check whether that is what you want.

    1. Create a measure as below to get the sum of stock base on the specific conditions

    Measure = 
    VAR _maxdate =
        MAX ( 'Date'[Date] )
    VAR _selweekedning =
        SELECTEDVALUE ( 'Date'[Week Ending] )
    RETURN
        IF (
            _maxdate < _selweekedning,
            BLANK (),
            CALCULATE (
                SUM ( 'Table'[Stock] ),
                FILTER ( 'Table', 'Table'[Date] <= _maxdate )
            )
        )

    2. Create another measure to get the correct total values

    Measure 2 = SUMX ( VALUES ( 'Date'[Week Ending] ), [Measure] )

    Best Regards