Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Count a number of months after registration

Greetings,   I have a task that seems simple, but I can't address it.   There are 2 linked tables 1. Dates (with columns Date, Month, Year, Month+Year) 2. Clients (Client ID and Registration da...
  • v-lid-msft's avatar
    v-lid-msft
    6 years ago

    Hi Anonymous ,

     

    We can try to use the following measure to meet your requirement:

     

    Measure = 
    VAR d =
        MIN ( 'Dates'[Date] )
    RETURN
        AVERAGEX (
            FILTERS('Clients'[Client ID]),
            var i = [Client ID] 
            var r =
            DATEDIFF (
                CALCULATE (
                    MIN ( 'Clients'[Registration date] ),
                    FILTER (
                        ALLSELECTED(  'Clients' ),
                        'Clients'[Client ID] = i
                    )
                ),
                d,
                MONTH
            )
            return IF(r>0,r,BLANK())
        )
        

     


    Best regards,