Group orders in the same cell, regarding the scheduled hour and supplyer name.

HUHA

New Member
Joined
Dec 7, 2019
Messages
10
Office Version
  1. 365
Platform
  1. Windows
Hello.
I have a table the following data :

ABCD
1​
Supplyer nameOrder numberScheduled dateScheduled hour
2​
Supplyer 100421492
20191209​
1100​
3​
Supplyer 100421493
20191209​
1100​
4​
Supplyer 100421604
20191209​
1100​
5​
Supplyer 200421605
20191209​
1100​
6​
Supplyer 300416136
20191209​
1200​
7​
Supplyer 300416155
20191209​
1300​
8​
Supplyer 300416161
20191209​
1400​
9​
Supplyer 500421938
20191209​
900​
10​
Supplyer 400421970
20191209​
600​
11​
Supplyer 400421971
20191209​
600​
12​
Supplyer 400421972
20191209​
600​
13​
Supplyer 400422126
20191209​
600​
14​
Supplyer 400422127
20191209​
600​



I need some help to bring the data in this format
When i have the same scheduled hour for the same supplyer , the order numbers to come in the same cell, with "/" betwen them, on one row
If i have different scheduled hours for the same supplyer, then to have the orders on the same cell only if the hour is the same.


Supplyer nameOrdersScheduled hour
Supplyer 100421492/00421493/004216041100
Supplyer 2004216051100
Supplyer 3004161361200
Supplyer 3004161551300
Supplyer 3004161611400
Supplyer 400421970/00421971/00421972/00422126/00422127600
Supplyer 500421938900

what the formula should be ?

Thank you in Advance
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
with Power Query

Supplyer nameOrder numberScheduled dateScheduled hourSupplyer nameOrdersScheduled hour
Supplyer 1421492201912091100Supplyer 1421492/421493/4216041100
Supplyer 1421493201912091100Supplyer 24216051100
Supplyer 1421604201912091100Supplyer 3416136/416155/4161611200
Supplyer 2421605201912091100Supplyer 3416136/416155/4161611300
Supplyer 3416136201912091200Supplyer 3416136/416155/4161611400
Supplyer 3416155201912091300Supplyer 4421970/421971/421972/422126/422127600
Supplyer 3416161201912091400Supplyer 5421938900
Supplyer 542193820191209900
Supplyer 442197020191209600
Supplyer 442197120191209600
Supplyer 442197220191209600
Supplyer 442212620191209600
Supplyer 442212720191209600


Code:
// Table1
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Grp = Table.Group(Source, {"Supplyer name"}, {{"Count", each _, type table}}),
    Orders = Table.AddColumn(Grp, "Orders", each List.Distinct(Table.Column([Count],"Order number"))),
    Extract = Table.TransformColumns(Orders, {"Orders", each Text.Combine(List.Transform(_, Text.From), "/"), type text}),
    Hours = Table.AddColumn(Extract, "Scheduled hour", each List.Distinct(Table.Column([Count],"Scheduled hour"))),
    Expand = Table.ExpandListColumn(Hours, "Scheduled hour"),
    Sort = Table.Sort(Expand,{{"Supplyer name", Order.Ascending}}),
    Type = Table.TransformColumnTypes(Sort,{{"Scheduled hour", Int64.Type}, {"Orders", type text}})
in
    Type
 
Upvote 0
Thank you sandy66 for your input.
Now i try to replicate in Power Query how to do it. Is there a windows, where can i write your text , in the window of power query editor ?
 
Upvote 0
if you want create it from the beginning select your "table" and from the ribbon - data - find there From Table
it will open PowerQuery Editor, then you can replicate steps from the post
 
Upvote 0
thank you very much.
I did it, i put your code in Advance editor from power query editor
 
Upvote 0
It does not work like intended.
If you look at the results of Supplyer 3 , it should be only one order at every Scheduled hour .
416136 for scheduled hour 1200
416155 for scheduled hour 1300
416161 for scheduled hour 1400

the code does not look at the scheduled hour.

Do you know how to improve the code to take into consideration the scheduled hour, not only the Supplyer name ?
 
Upvote 0
i think i did it

Here

Grp = Table.Group(Source, {"Supplyer name"}, {{"Count", each _, type table}}),


i add

Grp = Table.Group(Source, {"Supplyer name" , "Scheduled hour "}, {{"Count", each _, type table}}),
 
Upvote 0
very well, congrats :)
so whole code looks like this:
Code:
// Table1
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Grp = Table.Group(Source, {"Supplyer name", "Scheduled hour"}, {{"Count", each _, type table}}),
    Orders = Table.AddColumn(Grp, "Orders", each List.Distinct(Table.Column([Count],"Order number"))),
    Extract = Table.TransformColumns(Orders, {"Orders", each Text.Combine(List.Transform(_, Text.From), "/"), type text}),
    Sort = Table.Sort(Extract,{{"Supplyer name", Order.Ascending}}),
    Reorder = Table.ReorderColumns(Sort,{"Supplyer name", "Count", "Orders", "Scheduled hour"}),
    Type = Table.TransformColumnTypes(Reorder,{{"Scheduled hour", Int64.Type}, {"Orders", type text}})
in
    Type

error humanum est
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,461
Messages
6,124,955
Members
449,199
Latest member
Riley Johnson

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