Power Query [Index]/List.Max([Index])

ahmetkeles

New Member
Joined
May 9, 2020
Messages
2
Office Version
  1. 2013
Platform
  1. Windows
Hello;
I have a table looks like the sample below.

.
Sample Data.png

I aplly these Power Query steps to my data:

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Name", type text}, {"Point", Int64.Type}}),
    #"Sorted Rows" = Table.Sort(#"Changed Type",{{"Test", Order.Ascending}}),
    #"Added Index" = Table.AddIndexColumn(#"Sorted Rows", "Dizin", 1, 1),
    #"Added Column" = Table.AddColumn(#"Added Index", "Special", each [Index]/List.Max(#"Added Index"[Index])),
    #"Added Column1" = Table.AddColumn(#"Added Column", "New Point", each [Point]*[Special]),
    #"Removed Columns" = Table.RemoveColumns(#"Added Column1",{"Index", "Special"})
in
    #"Removed Columns"

I get this result.

Target.png

Since my table has 1200000 rows, it works very slow. Is there a way to make it faster?
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Maybe calculate List.Max only once and not 1.2 Mio times already helps.

Add a step "max" after your index. Same as your step but without table.addcolumn part.

Then insert a step that refers again to the addindex and add your calculation referring tot max.
 
Upvote 0
With the code below, at my end it loaded records by approx 20K-25K a time. And took under 2 minutes to finish.
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Name", type text}, {"Point", Int64.Type}}),
    #"Sorted Rows" = Table.Sort(#"Changed Type",{{"Test", Order.Ascending}}),
    #"Added Index" = Table.AddIndexColumn(#"Sorted Rows", "Index", 1, 1),
    Last = Table.RowCount(#"Added Index"),
    #"Added Column" = Table.AddColumn(#"Added Index", "Special", each [Index]/Last),
    #"Added Column1" = Table.AddColumn(#"Added Column", "New Point", each [Point]*[Special]),
    #"Removed Columns" = Table.RemoveColumns(#"Added Column1",{"Index", "Special"})
in
    #"Removed Columns"
 
Upvote 0
That's very good to read.
 
Upvote 0

Forum statistics

Threads
1,214,376
Messages
6,119,181
Members
448,871
Latest member
hengshankouniuniu

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