Forum Discussion

joaquinel's avatar
joaquinel
Helper I
3 years ago

Calculating Previous Month

Hi,

 

I have a simple formula but cannot obtain the same info for the previous month. Could you please help me? Thank you.

 

calculate(DISTINCTCOUNT(Pagos[IdPersonaOrigen]),  Pagos[FechaInicioValidez] <= MAX('1CalFInicio'[Date]) )

1 Reply

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    joaquinel So normally a "previous month" measure looks something along the lines of:

    PM Measure =
      VAR __CurrentDate = MAX('1CalFlnicio'[Date])
      VAR __PMEnd = EOMONTH(__CurrentDate, -1)
      VAR __PMBegin = DATE(YEAR(__PMEnd), MONTH(__PMEnd), 1)
      VAR __Table = FILTER(ALL('Pagos'), [FechanlnicioValidez] >= __PMBegin && [FechanlnichioValidez\ <= __PMEnd)
      VAR __Result = COUNTROWS(DISTINCT(SELECTCOLUMNS('Pagos', "__Id", [IdPersonaOrigen])))
    RETURN
      __Result