Forum Discussion
How to count all people active using start date / end date columns ?
Hello everybody !
We have a list of people with a start date & end date.
I want to know how many people were active over time (meaning : start date < beginning of a period & end date > end of a period). The period being every month.
The result expected :
Jan 2018 - 18
Feb 2018 - 17
Mar 2018 - 18
Apr 2018 - 19
etc...
Not so obvious, I don't see how to create a measure for that. should I use a date table and an intermediate table to count for each different day ? it seems quite complicated, maybe there is an easier solution ? Thanks in advance !
Hi François,
i would think in your scenario you could use a disconnected date table as you would always be removing the filter context on the start date where you would likely be joined.
I following will work in that scenario
Measure = Calculate(countrows('table'),
filter('table', 'table'[startdate]< min('date'[date]) && 'table'[enddate] > max('date'[date]))If you are able to provide a sample file or data, I could give you a more exact formula
9 Replies
- richbenmintz
Resident Rockstar
Hi François,
i would think in your scenario you could use a disconnected date table as you would always be removing the filter context on the start date where you would likely be joined.
I following will work in that scenario
Measure = Calculate(countrows('table'),
filter('table', 'table'[startdate]< min('date'[date]) && 'table'[enddate] > max('date'[date]))If you are able to provide a sample file or data, I could give you a more exact formula
- Stachu
Community Champion
my guess is COUNTROWS with FILTER on your table with starts/ends dates - can you share how it looks?
- AnonymousNot applicable
Below are measures I use for this type of thing. The first two are what you're asking for, and I included some additional helpful ones since you may be doing something similar.
Note that these measures require the calDate to be used in the visual or as a filter because there is no relationship between the calendar and customer tables.
customerQty = COUNTROWS ( customers ) qtyActiveBeginningOfPeriod = CALCULATE ( customerQty , FILTER ( customers , startDate < min (calDate) && endDate > min (calDate)) ) qtyActiveEndOfPeriod = CALCULATE ( customerQty , FILTER (customers , endDate > max (calDate)) ) qtyRetainedBase = CALCULATE ( qtyActiveEndOfPeriod , FILTER ( customers , startDate < min (calDate)) ) qtyGrossNew = CALCULATE ( customerQty , FILTER ( customers , startDate >= min (calDate) && startDate <= max (calDate)) ) qtyNetNew = CALCULATE ( qtyGrossNew , FILTER ( customers , endDate > max (calDate)) )Usually after these measures, I build a summary table with SUMMARIZECOLUMNS by Year-Month, and I will relate that table to a calendar. Most of my visuals will be build on the summary table and another set of measures created against it.
- AnonymousNot applicable
Hi
Trying hard to get this to work.
Can you please show the DAX to build the summary table?
Regards, Henrik
- Ashish_Mathur
Super User
Hi,
Share some data and show the expected result.
- v-lili6-msft
Community Support