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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
slanka
Helper I
Helper I

How to calculate the value of combination of month and year from a date and compare?

My requirement is to calculate the records records within a particular month.

 

I have a month table separately and in other table i have startdate and enddate. All the dates in the month table are set to first date of each month. Startdate and Enddates are generated as per their start and end dates. Now, i need to count the number of records entered into the system on that particular month.

 

I used DAX formula as IF(StartDate <= MonthDate && EndDate >= MonthDate, 1, 0). 

 

Issue here is, as MonthDate is set to starting of every month, when the StartDate is greater than the MonthDate , record is not getting counted (though it's in the same month).

(Example: StartDate = 03/10/2019, EndDate = 12/31/2019, MonthDate = 03/01/2019). I need to do a calculation ONLY based on month and year value.

 

Appreciate any help.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi

 

To avoid "StartDate" be later than "MonthDate", take the first day of the month of "StarDate" to compare with "MonthDate":

 

 

COUNT = IF(DATE(YEAR(StarDate), MONTH(StartDate), 1) <= MonthDate && EndDate >= MonthDate, 1, 0)

 

 

I hope this help you.

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi

 

To avoid "StartDate" be later than "MonthDate", take the first day of the month of "StarDate" to compare with "MonthDate":

 

 

COUNT = IF(DATE(YEAR(StarDate), MONTH(StartDate), 1) <= MonthDate && EndDate >= MonthDate, 1, 0)

 

 

I hope this help you.

This did my job easier. Thanks!

Greg_Deckler
Community Champion
Community Champion

Sample data would help. 


That being said, take a look at these two Quick Measures as I think you want something like them.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Open-Tickets/m-p/409364
https://community.powerbi.com/t5/Quick-Measures-Gallery/Periodic-Billing/m-p/409365



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

This works for me, but i need to add couple of calculated columns and do further calculation. Thanks a lot for the reply!!!

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors
Top Kudoed Authors