Forum Discussion

PalexRF's avatar
PalexRF
Regular Visitor
8 years ago
Solved

How to count months in filter?

Hello. 

I have a filter from the calendar table.
I need to calculate the number of months between the start date and the end date of the filter. How can i do this? Thanks in advance for answers

  • add a measure

     

    number of months = DATEDIFF(Min(Calendar[Date]) MAX(Calendar[Date]), Month)

4 Replies

  • add a measure

     

    number of months = DATEDIFF(Min(Calendar[Date]) MAX(Calendar[Date]), Month)
    • PalexRF's avatar
      PalexRF
      Regular Visitor

      Thank you for an answer.

      I used this construction. But it returns all dates in calendar table. But i need only filtered dates.

      ex.  I have calendar table with dates from 2010 to 2017. And i set filter on sheet only for 2016 year. So i need to get 12 months in result. But your formula will return all months from 2010 to 2017.

      • parry2k's avatar
        parry2k
        Icon for Super User rankSuper User

        I just test the same thing at my end and it worked as expected. Not sure what else is going on at your end? Any relationship with other table or something else is making it not to work, one improvment I need to do in my formulat is to add one to it, that will be give true number.