1) Group All Rows 2) Table.Max with Condition

Janardhan

New Member
Joined
Jan 2, 2018
Messages
8
[TABLE="class: grid, width: 250"]
<tbody>[TR]
[TD]Data[/TD]
[TD]Sub[/TD]
[TD]Amount[/TD]
[/TR]
[TR]
[TD]A[/TD]
[TD]WWW[/TD]
[TD]98[/TD]
[/TR]
[TR]
[TD]A[/TD]
[TD]XXX[/TD]
[TD]65[/TD]
[/TR]
[TR]
[TD]A[/TD]
[TD][/TD]
[TD]88[/TD]
[/TR]
[TR]
[TD]B[/TD]
[TD]GGG[/TD]
[TD]25[/TD]
[/TR]
[TR]
[TD]B[/TD]
[TD][/TD]
[TD]77[/TD]
[/TR]
[TR]
[TD]B[/TD]
[TD]HHH[/TD]
[TD]43[/TD]
[/TR]
[TR]
[TD]C[/TD]
[TD]JJJ[/TD]
[TD]65[/TD]
[/TR]
[TR]
[TD]C[/TD]
[TD]OOO[/TD]
[TD]99[/TD]
[/TR]
[TR]
[TD]C[/TD]
[TD]SSS[/TD]
[TD]73[/TD]
[/TR]
[TR]
[TD]D[/TD]
[TD][/TD]
[TD]66[/TD]
[/TR]
</tbody>[/TABLE]

Result:confused:

[TABLE="class: grid, width: 250"]
<tbody>[TR]
[TD]Data[/TD]
[TD]Sub[/TD]
[TD]Amount[/TD]
[/TR]
[TR]
[TD]A[/TD]
[TD]WWW[/TD]
[TD]98[/TD]
[/TR]
[TR]
[TD]B[/TD]
[TD]HHH[/TD]
[TD]43[/TD]
[/TR]
[TR]
[TD]C[/TD]
[TD]OOO[/TD]
[TD]99[/TD]
[/TR]
[TR]
[TD]D[/TD]
[TD][/TD]
[TD]66[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Please Help,
Its Urgent,
I want Max Amount of Data & Sub, if Sub is Blank with one row then ok,
if Sub is blank or non blank with multiple rows, then non blank will appear as Max
 
Upvote 0
Please Help,
Its Urgent,
I want Max Amount of Data & Sub, if Sub is Blank with one row then ok,
if Sub is blank or non blank with multiple rows, then non blank will not appear as Max
 
Upvote 0
Please Help,
Its Urgent,
I want Max Amount of Data & Sub, if Sub is Blank with one row then ok,
if Sub is blank and non blank with multiple rows, then non blank will not appear as Max
 
Upvote 0
Multiple posts make it look like your question was already answered, so that makes it take even longer
And posting three times in ten minutes is just rude
That said, here is some code that does what it seems you want
Code:
let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
CT  = Table.TransformColumnTypes(Source,{{"Data", type text}, {"Sub", type text}, {"Amount", Int64.Type}}),
NoNull = Table.SelectRows(CT, each ([Sub] <> null)),
YesNull = Table.SelectRows(CT, each ([Sub] = null)),
#"Merged Queries" = Table.NestedJoin(YesNull,{"Data"},NoNull,{"Data"},"NoNull",JoinKind.LeftOuter),
#"Expanded NotNullTable" = Table.ExpandTableColumn(#"Merged Queries", "NoNull", {"Sub"}, {"NoNull.Sub"}),
#"Filtered Rows" = Table.SelectRows(#"Expanded NotNullTable", each ([NoNull.Sub] = null)),
#"Grouped Rows" = Table.Group(#"Filtered Rows", {"Data"}, {{"Max", each List.Max([Amount]), type number}}),
#"Grouped Rows1" = Table.Group(NoNull, {"Data"}, {{"Max", each List.Max([Amount]), type number}}),
Combined = #"Grouped Rows"  & #"Grouped Rows1",
#"Merged Queries1" = Table.NestedJoin(Combined,{"Data", "Max"},CT,{"Data", "Amount"},"CT",JoinKind.LeftOuter),
#"Expanded CT" = Table.ExpandTableColumn(#"Merged Queries1", "CT", {"Sub"}, {"Sub"}),
#"Sorted Rows" = Table.Sort(#"Expanded CT",{{"Data", Order.Ascending}}),
#"Reordered Columns" = Table.ReorderColumns(#"Sorted Rows",{"Data", "Sub", "Max"}),
#"Renamed Columns" = Table.RenameColumns(#"Reordered Columns",{{"Max", "Amount"}}) 
in #"Renamed Columns"
 
Upvote 0

Forum statistics

Threads
1,226,230
Messages
6,189,770
Members
453,568
Latest member
LaTwiglet85

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