Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Calculate Mutiple date

Hello, I have searched many forums and could not find an answer, I hope you can help me. I am posting an example of my data below : I also have a table "Calendrier", that is a calendar table...
  • johnt75's avatar
    johnt75
    3 years ago

    Try changing it to

    My Measure =
    VAR ReferenceDate =
        MAX ( 'Calendar'[Date] )
    VAR StartDate =
        EOMONTH ( ReferenceDate, -1 ) + 1
    VAR EndNextMonth =
        EOMONTH ( ReferenceDate, 1 )
    VAR EndThisMonth =
        EOMONTH ( ReferenceDate, 0 )
    VAR Result =
        CALCULATE (
            COUNTROWS ( 'Top' ),
            REMOVEFILTERS ( 'Calendar' ),
            TREATAS (
                DATESBETWEEN ( 'Calendar'[Date], StartDate, EndNextMonth ),
                'Top'[End date]
            ),
            TREATAS (
                DATESBETWEEN ( 'Calendar'[Date], StartDate, EndThisMonth ),
                'Top'[Start date]
            ),
            'Top'[Type] <> 1
        )
    RETURN
        Result