Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Check if subscription is new or modification in subscription

Hello,   I have a dataset with subscriptions and  I want to make a binary dummy variable that indicates if a subscription is a modification in subscription or if it is a new subscription. A "start ...
  • v-easonf-msft's avatar
    6 years ago

    Hi ,  Anonymous 

    If I didn't misunderstand your meaning,you can try the following steps:

    First , you need to sort the table by “Relationshipnumber” and “starting date”.

    Then, a index column  is needed to be inserted into the table to help you create DAX.( You can right-click to hide the created index column if you don't need to display it )

    Finally , you  can create calculate columns “Start Subscription modification1” and “End Subscription modification1” like that :

     

    Start Subscription modification1 = 
    var ed = 'Table'[Starting date]
    var ind = 'Table'[Index]-1
    var sti = CALCULATE(MAX('Table'[End  date] ),FILTER('Table','Table'[Index] = ind))
    var days=DATEDIFF(sti,ed,DAY)
    var val=IF(days<=14&&days>=0,1)
    return 
    IF(days<>BLANK(),val,BLANK()
    )
    End Subscription modification1 = 
    var ed = 'Table'[End  date]
    var ind = 'Table'[Index]+1
    var sti = CALCULATE(MAX('Table'[Starting date]),FILTER('Table','Table'[Index] = ind))
    var days=DATEDIFF(ed,sti,DAY)
    var val=IF(days<=14&&days>0,1) 
    return 
    IF(days<>BLANK(),val,BLANK())

     

    Here is a sample  I made:

    url:  https://wicren-my.sharepoint.com/:u:/g/personal/michael_wicren_onmicrosoft_com/ES0w8BWanIlOsOfDEHhRUv8BU9apCd06vfTzctIc4sMc-w?e=J3YEbr 

     

    Best Regards,

    Eason

    Community Support Team _ Eason Fang

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.