Bring the date of the next row

Jose Fonyat

New member
Joined
Aug 30, 2017
Messages
13
Reaction score
0
Points
0
Location
Brazil
Excel Version(s)
Microsoft 365 Apps Versao 2007
Dear members, good evening !!

Let me know if you can help me with this problem:

My table is like the one below:

DateProjectNumContractCustomerNameTypeContractPointsAmountBalancePointsStatus
01/01/2017410Alan James150000 Pts150.0005.000100.000Active
31/01/2017315Bill Smith300.000 Pts300.00010.000250.000Reverted
10/02/2017216Bill Smith150.000 Pts150.0005.00050.000Active
15/02/2017121John Bradley150.000 Pts150.0005.00080.000Reverted
28/02/2017527John Bradley75.000 Pts75.0002.50055.000Reverted
01/03/2017628John Bradley30.000 Pts30.0006.50030.000Active

My goal is to add a new conditional column and insert a date according to the following conditions:

1. the Customer Name appears at least in two or more records (repeated)
2. The date to be inserted is the date of the next record

DateProjectNumContractCustomerNameTypeContractPointsAmountBalancePointsStatusDate Reverted
01/01/2017410Alan James150000 Pts150.0005.000100.000Activenull
31/01/2017315Bill Smith300.000 Pts300.00010.000250.000Reverted31/01/2017
10/02/2017216Bill Smith150.000 Pts150.0005.00050.000Activenull
15/02/2017121John Bradley150.000 Pts150.0005.00080.000Reverted28/02/2017
28/02/2017527John Bradley75.000 Pts75.0002.50055.000Reverted01/03/2017
01/03/2017628John Bradley30.000 Pts30.0006.50030.000Activenull

Thanks for the support
Best Regards
 

Does this work for you?

Code:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Added Index" = Table.AddIndexColumn(Source, "Index", 0, 1),
    #"Added Conditional Column" = Table.AddColumn(#"Added Index", "Date Reverted", each if [CustomerName] = #"Added Index"{[Index] + 1}[CustomerName] then #"Added Index"{[Index] + 1}[Date] else null)
in
    #"Added Conditional Column"

It produces the following:
Note, you had Bill Smith's value at 31/01/2017, but I assume that's a misprint and you want the next value which is 10/02/2017?

DateProjectNumContractCustomerNameTypeContractPointsAmountBalancePointsStatusIndexDate Reverted
01/01/2017410Alan James150000 Pts1505100Active0
31/01/2017315Bill Smith300.000 Pts30010250Reverted110/02/2017
10/02/2017216Bill Smith150.000 Pts150550Active2
15/02/2017121John Bradley150.000 Pts150580Reverted328/02/2017
28/02/2017527John Bradley75.000 Pts752.555Reverted401/03/2017
01/03/2017628John Bradley30.000 Pts306.530Active5

BTW: I don't have it in the M-Code, but I'd recommend to add a sort step before the conditional column step, else you'd get undesired results!
 
Last edited:
Thanks a lot Rudi!

The code works fine..

Best Regards
 
Back
Top