Forum Discussion

mattyj2009's avatar
mattyj2009
Icon for Helper II rankHelper II
7 years ago
Solved

Working with date ranges to find initial install date count

Good Afternoon,   I was trying to find a way to pull numbers using a date range.  We are wanting to check when a service was initially installed and have that show as an initial install count.    ...
  • v-cherch-msft's avatar
    7 years ago

    Hi mattyj2009 

    You may add index first and then create columns and measures as below.Attached sample file for your reference.

    Last_DisconnectDate = 
    VAR last_Dis_date =
        CALCULATE (
            MAX ( Data[Disconnect Date] ),
            FILTER (
                ALLEXCEPT ( Data, Data[Address ID] ),
                Data[Index]
                    = EARLIER ( Data[Index] ) - 1
            )
        )
    RETURN
        IF ( last_Dis_date = BLANK (), Data[Disconnect Date], last_Dis_date )
    
    New_index = IF(Data[Install Date]>Data[Last_DisconnectDate],Data[Index],0)
    Count = 
    VAR min_date =
        CALCULATE (
            MIN ( Data[Install Date] ),
            FILTER (
                ALL ( Data ),
                Data[Address ID] = MAX ( Data[Address ID] )
                    && Data[New_index] = MAX ( Data[New_index] )
            )
        )
    RETURN
        CALCULATE (
            DISTINCTCOUNT ( Data[Address ID] ),
            FILTER ( Data, IF ( Data[Install Date] = min_date, 1 ) )
        )
    
    CountSum = SUMX(VALUES(Data[Install Date]),[Count])

    Regards,