Forum Discussion
mattyj2009
Helper II
7 years agoWorking 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. ...
- 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,
v-cherch-msft
Microsoft Employee
7 years agoHi 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,
- mattyj20097 years ago
Helper II
This is exactly what I needed. I really appreicate your help. Have a great day!!!