Forum Discussion

azaterol's avatar
azaterol
Icon for Helper V rankHelper V
2 years ago
Solved

Calculate previous Day together

Hello everyone,   I have a matrix with year, month and day. I would now like to see another subtotal displayed. If possible, the intermediate result should be displayed above each day.   I've tr...
  • amitchandak's avatar
    2 years ago

    azaterol , if you are currently using one measure in matrix visual. You can use 2 and use option Switch values on rows.

     

    the second measure can be a distinct count for the last 2 days. Prefer date table, joined with the date of your table

    Rolling 2 = CALCULATE(distinctcount('Customers'[ID]),DATESINPERIOD('Date'[Date],MAX('Date'[Date]),-2,day))

     

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi amitchandak ,thanks for the quick reply, I'll add more.

    Hi azaterol ,

    The Table data is shown below:

    Use the following DAX expression to create a measure

    Measure2 =
    VAR _currentDate =
        SELECTEDVALUE ( 'Table'[Date] )
    VAR _previousDate = _currentDate - 1
    RETURN
        CALCULATE (
            COUNTROWS ( DISTINCT ( 'Table'[Member ID] ) ),
            ALL ( 'Table'[Date] ),
            'Table'[Date] >= _previousDate
                && 'Table'[Date] <= _currentDate
        )
    

    Final output

     

    Best Regards,
    Wenbin Zhou