cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
kastriot Frequent Visitor
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

 

pbi.PNG

1 ACCEPTED SOLUTION

Accepted Solutions
themistoklis New Contributor
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
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.