Forum Discussion

kastriot's avatar
kastriot
Frequent Visitor
7 years ago
Solved

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

 

  • 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

  • themistoklis's avatar
    themistoklis
    Community Champion

    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.