Power Query- earliest and lasted dates from multiple columns.

Mendy32

New Member
Joined
Dec 23, 2019
Messages
36
Office Version
  1. 2019
Platform
  1. Windows
I’m a started using PowerQuery and it has really made my working life much easier. Especially merging tables together...what I need help with is finding the earliest and latest dates from multiple columns 3-7. I have about 7200 rows..For example:

Column headers

1. name
2. Customer ID
3. IRCL date
4. IRFI date
5. iRMJ date
6. IRMC date
7. Tran date...

I know I have to add two additional columns to find the earliest date from 3-7 and lastest date 3-7. Also some dates will be missing from the rows cause not all customer went through columns 3-7.
Can you please help me...
 
You are most welcome :)

Customer IDIRCLIRFIIRMJIRMCTrain
aa12/02/201014/02/201016/02/2010
aa01/02/202003/02/202007/02/202009/02/2020
bb17/01/202019/01/202020/01/202021/01/2020
bb20/02/202022/02/202024/02/202028/02/2020
Customer IDEarliest dateLatest date
aa12/02/201009/02/2020
bb17/01/202028/02/2020

Code:
// Table3
let
    Source = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],
    Unpivot = Table.UnpivotOtherColumns(Source, {"Customer ID"}, "Attribute", "Value"),
    Group = Table.Group(Unpivot, {"Customer ID"}, {{"Earliest date", each List.Min([Value]), type datetime}, {"Latest date", each List.Max([Value]), type datetime}}),
    #"Changed Type" = Table.TransformColumnTypes(Group,{{"Earliest date", type date}, {"Latest date", type date}})
in
    #"Changed Type"
 
Last edited:
Upvote 0

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

Forum statistics

Threads
1,223,246
Messages
6,170,988
Members
452,373
Latest member
TimReeks

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top