Forum Discussion

Unknowncharacte's avatar
Unknowncharacte
Helper III
2 years ago

Count for Previous Month, Data for multiple Years

Hi, 

 

I am trying to calculate a count for previous month taking into account data that spans across multple years. 

I have a calendar table connected to my fact table, here are my two measures:

 

Complaints Closed =
CALCULATE(
    DISTINCTCOUNT('Fact Table'[HR Compaint]))
 
Complaints Closed Previous Month =
CALCULATE([Complaints Closed],
DATEADD('Calendar'[Date],-1,MONTH))


So I need to account for the year as well, it has to be previous calendar month for 2023.

 

Here is a small sample of my data:
Sample Data.pbix

4 Replies

  • what's the expected output for the sample data you provided?

    • Unknowncharacte's avatar
      Unknowncharacte
      Helper III

      In the sample PowerBI dataset, I have a card showing the # I need. 

      I just want the # of Closed HR compaints for previous month - Septermber 2023

      The complication is comes in with multiple years in the dataset, also, when it's January 2024, the calculation has to account for previous month and year = December 2023