cancel
Showing results for
Search instead for
Did you mean:
kastriot Frequent Visitor

## Count based on two date columns

Hello,

I am trying to count values in [Staff ID] only if the month and year of [ExitDate] match the month and year of [ReportingDate] and I was hoping someone can help me.

Thank you 1 ACCEPTED SOLUTION

Accepted Solutions
themistoklis New Contributor

## Re: Count based on two date columns

@kastriot

First add a calculated column using this formula:

`Column = IF(YEAR('Table'[ReportingDate]) = YEAR('Table'[Exit Date]) && MONTH('Table'[ReportingDate]) = MONTH('Table'[Exit Date]),1,0)`

Then add this measure:

`Measure = CALCULATE(COUNT('Table'[Staff ID]), 'Table'[Column] = 1)`

Workspace on this link.

1 REPLY 1
themistoklis New Contributor

## Re: Count based on two date columns

@kastriot

First add a calculated column using this formula:

`Column = IF(YEAR('Table'[ReportingDate]) = YEAR('Table'[Exit Date]) && MONTH('Table'[ReportingDate]) = MONTH('Table'[Exit Date]),1,0)`

Then add this measure:

`Measure = CALCULATE(COUNT('Table'[Staff ID]), 'Table'[Column] = 1)`

Workspace on this link.