Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
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
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.
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.
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
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.
From that point I applied these steps:
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
Hope this helps.
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
#"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.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
15 | |
10 | |
10 | |
8 | |
7 |