Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Unknowncharacte
Helper III
Helper III

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 4
ryan_mayu
Super User
Super User

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





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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

have you tried to use USERELATIONSHIP to activate the inactive relationship?

 

USERELATIONSHIP function (DAX) - DAX | Microsoft Learn

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




I have a direct connection between tables, issue is not with that....

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.