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

Calculate Prior Date based on unique field

Hello,

 

In the list below, for each row, I need to find the next effective date (effdt) based [PlanLink], sort of like a sumifs in Excel. What I am trying to do is get each effective date's End Date by finding its next effective date and subtracting a day. In the instances were the latest plan is still the most recent I just want to set the end date as some far off date like 12/31/2099 or something.

 

I have included a live data set as well as manually assigned the first several rows on [EndDate] to illustrate what I am trying to do. Again, each EndDate should be looking at EffDtg and unique [PlanLink] fields.

 

 

Customer_IDContractEffDtMapPlan NamePlanLinkEndDate
2990916907601/01/14D0012737Bronze (PPO)0169076D0012737Bronze (PPO)12/31/14
2990916907601/01/15D0012737Bronze (PPO)0169076D0012737Bronze (PPO)12/31/15
2990916907601/01/16D0012737Bronze (PPO)0169076D0012737Bronze (PPO)12/31/16
2990916907601/01/17D0012737Bronze (PPO)0169076D0012737Bronze (PPO)12/31/99
2990916907601/01/14D0012738Silver (PPO)0169076D0012738Silver (PPO)12/31/14
2990916907601/01/15D0012738Silver (PPO)0169076D0012738Silver (PPO)12/31/15
2990916907601/01/16D0012738Silver (PPO)0169076D0012738Silver (PPO)12/31/16
2990916907601/01/17D0012738Silver (PPO)0169076D0012738Silver (PPO)12/31/99
2990916907601/01/14D0012739Gold (PPO)0169076D0012739Gold (PPO)12/31/14
2990916907601/01/15D0012739Gold (PPO)0169076D0012739Gold (PPO)12/31/15
2990916907601/01/16D0012739Gold (PPO)0169076D0012739Gold (PPO)12/31/16
2990916907601/01/17D0012739Gold (PPO)0169076D0012739Gold (PPO)12/31/99
2990916907601/01/16D0012745Platinum (DHMO)0169076D0012745Platinum (DHMO)12/31/16
2990916907601/01/17D0012745Platinum (DHMO)0169076D0012745Platinum (DHMO)12/31/99
2990916907601/01/16D0012751Platinum (DHMO)0169076D0012751Platinum (DHMO)12/31/16
2990916907601/01/17D0012751Platinum (DHMO)0169076D0012751Platinum (DHMO)12/31/99
2990916907601/01/16D0012794Platinum (DHMO)0169076D0012794Platinum (DHMO)12/31/16
2990916907601/01/17D0012794Platinum (DHMO)0169076D0012794Platinum (DHMO)12/31/99
2990916907601/01/16D0012795Platinum (DHMO)0169076D0012795Platinum (DHMO)12/31/16
2990916907601/01/17D0012795Platinum (DHMO)0169076D0012795Platinum (DHMO)12/31/99
2990916907601/01/16D0013549Platinum (DHMO)0169076D0013549Platinum (DHMO)12/31/16
2990916907601/01/17D0013549Platinum (DHMO)0169076D0013549Platinum (DHMO)12/31/99
25446622770401/01/16D0012737Bronze (PPO)0227704D0012737Bronze (PPO)12/31/99
25446622770401/01/16D0012738Silver (PPO)0227704D0012738Silver (PPO)12/31/99
25357624171401/01/07D0012739Gold (PPO)0241714D0012739Gold (PPO)12/31/07
25357624171401/01/08D0012739Gold (PPO)0241714D0012739Gold (PPO)12/31/99
6188524235901/01/18D0012737Bronze (PPO)0242359D0012737Bronze (PPO)12/31/17
6188524235901/01/18D0012738Silver (PPO)0242359D0012738Silver (PPO) 
6188524235901/01/18D0012739Gold (PPO)0242359D0012739Gold (PPO) 
6188524235901/01/18D0012745Platinum (DHMO)0242359D0012745Platinum (DHMO) 
6188524235901/01/18D0012751Platinum (DHMO)0242359D0012751Platinum (DHMO) 
6188524235901/01/18D0012794Platinum (DHMO)0242359D0012794Platinum (DHMO) 
6188524235901/01/18D0012795Platinum (DHMO)0242359D0012795Platinum (DHMO) 
6188524235901/01/18D0013549Platinum (DHMO)0242359D0013549Platinum (DHMO) 
2451970111501/01/05D0012737Bronze (PPO)0701115D0012737Bronze (PPO) 
2451970111501/01/05D0012738Silver (PPO)0701115D0012738Silver (PPO) 
2451970111501/01/05D0012739Gold (PPO)0701115D0012739Gold (PPO) 
15725270414004/01/16D0012737Bronze (PPO)0704140D0012737Bronze (PPO) 
15725270414001/01/17D0012737Bronze (PPO)0704140D0012737Bronze (PPO) 
15725270414001/01/18D0012737Bronze (PPO)0704140D0012737Bronze (PPO) 
15725270414004/01/16D0012738Silver (PPO)0704140D0012738Silver (PPO) 
15725270414001/01/17D0012738Silver (PPO)0704140D0012738Silver (PPO) 
15725270414001/01/18D0012738Silver (PPO)0704140D0012738Silver (PPO) 
15725270414004/01/16D0012739Gold (PPO)0704140D0012739Gold (PPO) 
1 ACCEPTED SOLUTION
v-cherch-msft
Employee
Employee

Hi @Anonymous

 

You may add an index column in query editor first. Then you may create the below calculated columns.

Group =
IF (
    Table4[PlanLink]
        = LOOKUPVALUE ( Table4[PlanLink], Table4[Index], Table4[Index] + 1 ),
    0,
    1
)

 

EndDate =
IF (
    Table4[Group] = 0,
    LOOKUPVALUE ( Table4[EffDt], Table4[Index], Table4[Index] + 1 )
        - 1,
    DATEVALUE ( "12/31/2099" )
)

 

2.png

 

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-cherch-msft
Employee
Employee

Hi @Anonymous

 

You may add an index column in query editor first. Then you may create the below calculated columns.

Group =
IF (
    Table4[PlanLink]
        = LOOKUPVALUE ( Table4[PlanLink], Table4[Index], Table4[Index] + 1 ),
    0,
    1
)

 

EndDate =
IF (
    Table4[Group] = 0,
    LOOKUPVALUE ( Table4[EffDt], Table4[Index], Table4[Index] + 1 )
        - 1,
    DATEVALUE ( "12/31/2099" )
)

 

2.png

 

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.