Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

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!

  • 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
     

     

    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 

     

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

     

3 Replies