Grouping Rows

rec161

New Member
Joined
Mar 16, 2020
Messages
4
Office Version
  1. 365
Platform
  1. Windows
I am trying to find a function that will group rows together in the "Incremental" column based on the value of the MFPart column.... following the SequenceNum

Example: IDs 7418314-7418329 would be value "1" in Incremental column, 7418330-7418332 would be "2", 7418334 = "3", 7418333-7418338 = "4"

2020-03-16_14-38-02.gif
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
you want to group MFPart column or ID column?

btw. use shorter column names
 
Upvote 0
use Custom Column, name it Incremental the use this M-code:
Rich (BB code):
if [OrderltemAssemblylD] >= 7413314 and [OrderltemAssemblylD] <= 7413329 then 1 else if [OrderltemAssemblylD] >= 7413330 and [OrderltemAssemblylD] <= 7413332 then 2 else if [OrderltemAssemblylD] >= 7413334 and [OrderltemAssemblylD] <= 7413334 then 3 else if [OrderltemAssemblylD] >= 7413333 and [OrderltemAssemblylD] <= 7413338 then 4 else null
it will give you result below
incif.png
 
Upvote 0
thanks sandy but im trying to make a dynamic column using a formula, there are thousands of rows, not just the sample i showed
 
Upvote 0
your manual criteria has nothing to do with MFPart column,
so maybe be more descriptive with your logic (algorithm) or wait for someone else
 
Upvote 0
ill try to simplify the data to clarify what im looking for (sorry for the confusion!)

what im trying to do is increase the value of the IncrementalGrouping column everytime the MFPart number changes (sort sequence based on SeqNum)

does that help?

IDSeqNumMFPartIncrementalGrouping (Calculated Column)
11090441
21190441
31290441
41390352
51490352
61590443
71690443
81790443
 
Upvote 0
yes that is what i am trying to achieve. any suggestions on functions or formula to use?
 
Upvote 0
Rich (BB code):
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Group = Table.Group(Source, {"MFPart"}, {{"Count", each _, type table [OrderltemAssemblylD=number, Batch=text, MFPart=text, SequenceNum=number]}, {"Inc", each Table.RowCount(_), type number}}),
    Sort = Table.Sort(Group,{{"MFPart", Order.Ascending}}),
    Incremental = Table.AddIndexColumn(Sort, "Incremental", 1, 1),
    Expand = Table.ExpandTableColumn(Incremental, "Count", {"OrderltemAssemblylD", "Batch", "SequenceNum"}, {"OrderltemAssemblylD", "Batch", "SequenceNum"}),
    TSC = Table.SelectColumns(Expand,{"OrderltemAssemblylD", "Batch", "MFPart", "SequenceNum", "Incremental"})
in
    TSC
 
Upvote 0

Forum statistics

Threads
1,223,799
Messages
6,174,669
Members
452,576
Latest member
AlexG_UK

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