Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
Anonymous
Not applicable

Measure for using same date for two different calculations

Hello!

 

I have a table with customers and their first payment date as members and last payment date as members. And I need to create a visual which counts both with the same month as axis. If at all possible created as a measure and a virtual relation, because otherwise I would probably have created a new table in our DWH or created an inactive relationship.

 

I have tried quite a few different measure-solutions from the forum with USERELATIONSHIP, CROSSJOIN and I am probably doing something wrong.

 

So a sample data set could look like this:

MemberNumberFirstPaymentDateLastPaymentDate
Member 11. januar 20201. marts 2020
Member 21. januar 20201. januar 2020
Member 31. januar 20201. marts 2020
Member 41. februar 20201. marts 2020
Member 51. februar 20201. februar 2020
Member 61. februar 20201. marts 2020
Member 71. februar 20201. maj 2020
Member 81. marts 20201. marts 2020
Member 91. marts 20201. marts 2020
Member 101. marts 20201. maj 2020
Member 111. april 20201. april 2020
Member 121. april 20201. april 2020
Member 131. april 20201. maj 2020
Member 141. april 20201. april 2020
Member 151. april 20201. maj 2020
Member 161. maj 20201. maj 2020
Member 171. maj 20201. maj 2020
Member 181. maj 20201. maj 2020
Member 191. maj 20201. maj 2020
Member 201. maj 20201. maj 2020

 

And an output table would look like this with two 'measures':

DateNumber of new membersNumber of lapsed members
1. januar 202031
1. februar 202041
1. marts 202035
1. april 202053
1. maj 202059

 

Thank you so much!

1 ACCEPTED SOLUTION
negi007
Community Champion
Community Champion

@Anonymous here is the solution you can follow 

 

first create a new table with unique date values

Table 2 = DISTINCT(UNION(DISTINCT('table'[FirstPaymentDate]),DISTINCT('table'[LastPaymentDate])))
 
then create relationship between two tables
 
negi007_0-1616172123566.png

 

create two measures below

New_Member = count('table'[FirstPaymentDate])
Lapsed_Member = CALCULATE(count('table'[LastPaymentDate]),USERELATIONSHIP('Table 2'[FirstPaymentDate],'table'[LastPaymentDate]))
 
Below is the output you are looking for 
negi007_1-1616172173362.png

 

 here is also pbix file that you can refer to for help. I hope I have been able to resolve the issue. thanks cheers
 
 

 




Did I answer your question? Mark my post as a solution!
Appreciate your Kudos



Proud to be a Super User!


Follow me on linkedin

View solution in original post

3 REPLIES 3
negi007
Community Champion
Community Champion

@Anonymous here is the solution you can follow 

 

first create a new table with unique date values

Table 2 = DISTINCT(UNION(DISTINCT('table'[FirstPaymentDate]),DISTINCT('table'[LastPaymentDate])))
 
then create relationship between two tables
 
negi007_0-1616172123566.png

 

create two measures below

New_Member = count('table'[FirstPaymentDate])
Lapsed_Member = CALCULATE(count('table'[LastPaymentDate]),USERELATIONSHIP('Table 2'[FirstPaymentDate],'table'[LastPaymentDate]))
 
Below is the output you are looking for 
negi007_1-1616172173362.png

 

 here is also pbix file that you can refer to for help. I hope I have been able to resolve the issue. thanks cheers
 
 

 




Did I answer your question? Mark my post as a solution!
Appreciate your Kudos



Proud to be a Super User!


Follow me on linkedin

amitchandak
Super User
Super User
Anonymous
Not applicable

@negi007  @amitchandak 
Hi both! Thank you for the suggestions. As mentioned in the thread-post, is there a way to do this without creating a new table, to do it purely with measures? We are trying to avoid too many single-use tables in the DWH. (Obviously if there is no other solution, we will need to do it)

 

Best regards

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.