Forum Discussion

Belle2015's avatar
Belle2015
Icon for Helper II rankHelper II
1 year ago
Solved

Help with error when creating a measure for a date filter

Hi,  I have had some help in creating a measure to create a filter to show the previous day's data or the weekend's data on a Monday but I am getting the below error 'The expression refers to multip...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi, Belle2015 

    Based on your information, I create you table. At the same time, I added a piece of data from January 6th to test it.

    Then create a new measure:

     

    PreviousDayOrWeekendData = 
    VAR TodayIsMonday = WEEKDAY(MAX('Table'[Count Date]), 2) = 1
    VAR _PreviousDay = CALCULATE(SUM('Table'[TotalStockPlusDiff]), 'Table'[Count Date] = MAX('Table'[Count Date]) - 1)
    VAR WeekendData = CALCULATE(SUM('Table'[TotalStockPlusDiff]), WEEKDAY('Table'[Count Date], 2) IN {6, 7} && 'Table'[Count Date] <= MAX('Table'[Count Date]))
    RETURN
    IF(TodayIsMonday, WeekendData, _PreviousDay)

     

     

    Put this measure in table visual and create a slicer. Here is my preview:

     

    When you select a slicer, the metrics also change. At the same time, it calculates the sum of the weekends up to the date selected by the current slicer.

     

     

    How to Get Your Question Answered Quickly

    Best Regards

    Yongkang Hua

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