Forum Discussion
Active Clients Multiple Services
Here is an example of the type the data I'm using. Each client can have more than 1 service and I want to find clients active in a service within a time period (say between date x and date y) defined by a slicer on the report. The slicer is based off a date table created by using CALENDARAUTO(). So essentially I wanted to get a list of client references that have have a start date before y AND end date after x. Where x and y can be altered by a date slicer.
I was creating a filter on my visual using:
- Anonymous5 years ago
[# Active Clients] = var MinReportingPeriod = MIN( Datetable[Date] ), var MaxReportingPeriod = MAX( Datetable[Date] ) var Result = COUNTROWS( SUMMARIZE( CALCULATETABLE( ServiceInfo, KEEPFILTERS( ServiceInfo[Start Date] <= MaxReportingPeriod ), KEEPFILTERS( MinReportingPeriod <= ServiceInfo[End Date] ) ), ServiceInfo[Client Ref] ) ) return Result
8 Replies
- AnonymousNot applicable
[# Active Clients] = var MinReportingPeriod = MIN( Datetable[Date] ), var MaxReportingPeriod = MAX( Datetable[Date] ) var Result = COUNTROWS( SUMMARIZE( CALCULATETABLE( ServiceInfo, KEEPFILTERS( ServiceInfo[Start Date] <= MaxReportingPeriod ), KEEPFILTERS( MinReportingPeriod <= ServiceInfo[End Date] ) ), ServiceInfo[Client Ref] ) ) return Result- elinevans
Helper I
HI Anonymous, using the above gave a count of the acive clients but what I want is a list of the client references of those clients who are active. Am I applying it wrong?
Thanks
Elin
- AnonymousNot applicable
A measure can't return a table, only a scalar. When you say "a list of client references", what do you actually mean in this context? All you can return from a measure that imitates a list of values is a string with the values concatenated by using the CONCATENATEX function.
You can take my code from above and instead of returning the count of active clients, you can use the function to return a list of references as explained before.
- elinevans
Helper I
Anonymous
If you are referring to:
Active Clients = IF(MIN(ServiceInfo[Start Date]) <= MAX(Datetable[Date]) && MAX(ServiceInfo[End Date]) >= MIN(Datetable[Date]),1,0)It doesn't cover all eventualities. If the client has a service that starts and ends before the start of the reporting period, and another that starts and ends after the reporting period ends they will still be counted eventhough they are in active in reporting period.For example if a client had 2 services which are marked by the 2 red arrows:Sorry for all the confusion!
- AnonymousNot applicable
I'm talking about my measure. Did you see it? 'Cause I have a feeling you didn't...
- elinevans
Helper I
Apologies for wasting your time. I didn't apply it correctly the first time and didn't realise you could add it to a filter plane as a count. Thank you for your help!!