Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi,
I am working on a membership database where I would like to look at how many active members there were on a certain date in the past.
A member may have had different contracts over the course of time, meaning that they have been active in several, separeted periods of time. So the data looks something like this:
Customer | Contract | ContractStartDate | ContractEndDate |
A | 1 | 13.01.2014 | 18.06.2014 |
A | 2 | 21.09.2014 | 17.12.2014 |
B | 3 | 15.12.2014 | 29.12.2014 |
B | 4 | 18.01.2015 | 26.05.2016 |
This will eventually lead to cohort analysis, but for the time being I'd be happy to see how many active customers we had on, say, 16.12.2014, and what their names were.
The problem is creating the measure that will tell me if the customer had an active contract at the given date.... Any suggestions?
Solved! Go to Solution.
Hi @triggerturf,
Add a calendar table to your model, then add the following measure to your table:
Active/Inactive = VAR CalendarDate = MAX ( 'Calendar'[Date] ) RETURN IF ( CalendarDate >= MAX ( Membership[ContractStartDate] ) && CalendarDate <= MAX ( Membership[ContractEndDate] ), "Active", "Inactive" )
See the result below:
Regards,
MFelix
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsUpdate; Suggested solution works when removing existing / misleading relationships from model. Simply made new pbix based on existing data model to handle this challenge.
Hi @triggerturf,
Could you post your table structures(including the relationships) with some sample/mock data, so that we can further assist on this issue?
Regards
Thanks for offering, but due to the nature of person data and legislation it seems I would have to build a full mockup with sample data, which would take too much time right now (12 tables with total 11 active and 3 passive relationships).
I will try to get at the challenge from a different angle.
Hi @triggerturf,
Add a calendar table to your model, then add the following measure to your table:
Active/Inactive = VAR CalendarDate = MAX ( 'Calendar'[Date] ) RETURN IF ( CalendarDate >= MAX ( Membership[ContractStartDate] ) && CalendarDate <= MAX ( Membership[ContractEndDate] ), "Active", "Inactive" )
See the result below:
Regards,
MFelix
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsI see what is being done here, but I think that I getting stuck by a number of existing relationships to various tables in our data model. I have a feeling I have to extract some data/colums to a table without relationships to make this work, but it's outside my comfort zone / level of knowledge 🙂
Don't know how you model is setup but if you have a sample data or some explanation on how you have your model I can try an help you.
Regards,
MFelix
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsCovering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
106 | |
93 | |
75 | |
62 | |
50 |
User | Count |
---|---|
147 | |
107 | |
105 | |
87 | |
61 |