Forum Discussion
Identify dates in the last/previous month
I'm trying to create a column that will identify a date that is in the month prior to the current month.
I have a calculated column that returns a "Yes" if the date is in the current month as follows:
Closed This Month = IF ( YEAR ( 'Ops Data'[Closed Date] ) = YEAR ( TODAY () ) && MONTH ('Ops Data'[Closed Date] ) = MONTH ( TODAY () ), "Yes", "" )
What I want is a formula that will count the number of dates the month before and also take account of the change of year (so in January 2018 it will count the number of December 2017 dates, etc.)
Hopefully this is a relatively simple request. Any ideas?
Hi blindeye,
Please try this measure:
Count Dates = IF ( MONTH ( TODAY () ) = 1, CALCULATE ( COUNT ( 'Ops Data'[Closed Date] ), FILTER ( 'Ops Data', 'Ops Data'[Closed Date].[Year] = YEAR ( TODAY () ) - 1 && 'Ops Data'[Closed Date].[MonthNo] = 12 ) ), CALCULATE ( COUNT ( 'Ops Data'[Closed Date] ), FILTER ( 'Ops Data', 'Ops Data'[Closed Date].[Year] = YEAR ( TODAY () ) && 'Ops Data'[Closed Date].[MonthNo] = MONTH ( TODAY () ) - 1 ) ) )Best regards,
Yuliana Gu
4 Replies
- v-yulgu-msft
Microsoft Employee
Hi blindeye,
Please try this measure:
Count Dates = IF ( MONTH ( TODAY () ) = 1, CALCULATE ( COUNT ( 'Ops Data'[Closed Date] ), FILTER ( 'Ops Data', 'Ops Data'[Closed Date].[Year] = YEAR ( TODAY () ) - 1 && 'Ops Data'[Closed Date].[MonthNo] = 12 ) ), CALCULATE ( COUNT ( 'Ops Data'[Closed Date] ), FILTER ( 'Ops Data', 'Ops Data'[Closed Date].[Year] = YEAR ( TODAY () ) && 'Ops Data'[Closed Date].[MonthNo] = MONTH ( TODAY () ) - 1 ) ) )Best regards,
Yuliana Gu - Ashish_Mathur
Super User
Hi,
Try this for identifying whether the date is prior to the current month or not.
=IF('Ops Data'[Closed Date]<=EOMONTH('Ops Data'[Closed Date],-1),"Yes","No")
Hope this helps.