Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
MagikJukas
Resolver III
Resolver III

Max value from each table

Hello,

I would like to add a column to each table in the "Rows" column where it calculate the Max value from the Indexstart column.

 

thanks

 

MagikJukas_0-1687988297039.png

 

4 REPLIES 4
MagikJukas
Resolver III
Resolver III

Ok, I figured that out, it was simpler than I expected.

basically, I first of all groupped my table using the "function" All rows and calculating the max of the indext start.

this gave me a list of table with another column containing the max value for each table.

I simply expanded the column containing the tables, so that I have a table with all entries including the column with the max value for each set.

 

MagikJukas
Resolver III
Resolver III

Hello @collinsg 

thanks for your comment. 

I notcied my problem description was not clear.

in the code below, you apply the Max number from the list.

#"Rows + Max Indexstart" = Table.AddColumn(
#"Added Max Indexstart col",
"Copy Rows and Add Max Indexstart",
each Table.AddColumn(
[Rows],
"Max Indexstart",
each List.Max(#"Added Max Indexstart col"[Max Indexstart])
)
),

 

Instead I want to add number from each line, to the new table.

For instance, I want the first table to contain a new column with 1, and the second table a column with 566.

your solution was pushing the max (566) both tables.

 

MagikJukas_0-1688023672033.png

 

are you able to advise how to correct it? 

 

thanks

Good day @MagikJukas ,

I think I understand now - your description was fine, my error. Here is a suggestion based on my new understanding.

 

I created test data

collinsg_0-1688030931357.png

and loaded it into Power Query, grouping by Plant and Material Plant View to create a table with columns Plant, Material Plant View and Rows.

collinsg_1-1688031048956.png

From that point I applied these steps:

  1. Added a column with the max value of Indexstart for each Rows table.
  2. Expanded Rows
  3. Grouped by Plant and Material Plant View and using an "All Rows" aggregation. This aggregation brought the max Indexstart column into Rows.
  4. Since the "All Rows" aggregation also brought Plant and Material Plant View into Rows the last step is to remove them from it.

Here is the M code, assuming  your previous step is called "Previous Step"

#"Calculate Max Indexstart" = Table.AddColumn(
#"Previous Step",
"Max Indexstart",
each List.Max([Rows][Indexstart])),
#"Expanded Rows" = Table.ExpandTableColumn(
#"Calculate Max Indexstart",
"Rows",
{"Owner", "Customer", "Indexstart"}, {"Owner", "Customer", "Indexstart"}),
#"Grouped Rows" = Table.Group(
#"Expanded Rows",
{"Plant", "Material Plant View"},
{{"Rows", each _, type table [Plant=nullable number, Material Plant View=nullable text, Owner=text, Customer=text, Indexstart=nullable number, Max Indexstart=number]}}),
#"Remove Grouping Columns" = Table.TransformColumns(
#"Grouped Rows",
{ {"Rows", each Table.RemoveColumns(_, {"Plant","Material Plant View"})} } )

An example of the result is

collinsg_2-1688031314312.png

Hope this helps.

collinsg
Solution Sage
Solution Sage

Hello @MagikJukas ,

The following is an inelegant approach which creates temporary columns as stepping stones to the final result. I'm sure it could be made more elegant with some work. The code presumes your previous step is called "Previous Step". The method is

  1. Add a column which is "Max Indexstart".
  2. Add a column which is "Rows" with a "Max Indexstart" column added.
  3. Remove the temporary columns.
  4. Rename the "Copy Rows and Add Max Indexstart" column to "Rows".
#"Added Max Indexstart col" = Table.AddColumn(
#"Previous Step",
"Max Indexstart",
each List.Max([Rows][Indexstart])
),
#"Rows + Max Indexstart" = Table.AddColumn(
#"Added Max Indexstart col",
"Copy Rows and Add Max Indexstart",
each Table.AddColumn(
[Rows],
"Max Indexstart",
each List.Max(#"Added Max Indexstart col"[Max Indexstart])
)
),
#"Remove staging columns" = Table.RemoveColumns(#"Rows + Max Indexstart",{"Rows", "Max Indexstart"}),
#"Rename column as Rows" = Table.RenameColumns(#"Remove staging columns",{{"Copy Rows and Add Max Indexstart", "Rows"}})

 Hope this helps and that you find a more elegant solution.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.