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?
 

Some videos you may like

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

GraH

Well-known Member
Joined
Mar 22, 2020
Messages
604
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
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.
 

GraH

Well-known Member
Joined
Mar 22, 2020
Messages
604
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
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"
 

ahmetkeles

New Member
Joined
May 9, 2020
Messages
2
Office Version
  1. 2013
Platform
  1. Windows
Hi GraH;

Thanks for your help. It really works. I appreciate it.
 

GraH

Well-known Member
Joined
Mar 22, 2020
Messages
604
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
That's very good to read.
 

Watch MrExcel Video

Forum statistics

Threads
1,109,410
Messages
5,528,613
Members
409,828
Latest member
99DodgeRam

This Week's Hot Topics

  • Change military grades into rank
    Afternoon all Need help with formula that will change military rank (i.e. 1, 2, 3 into Amn, A1C, SrA). Running IF formula that does not work...
  • VBA COUNTIF SOLUTION
    Hi The following are the errors spread across the several columns from E to Q ie. 13 columns across several sheets with more than 500 rows per...
  • INSERT ROW WITH SPECIFIS TEXT IN A COLUMN
    Hi All! How can identify that that the row to be inserted has to be inserted before 1st row with specific text in column F. If I record the...
  • Auto-Create a monthly Sign in sheet for preschool students
    The image below is what each page looks like. Above is space for the "Child Name" "Month" "Class" School days are obviously Monday-Friday but...
  • VBA vlookup multiple results
    Hi folks, Hopefully someone out there can help. I have a list to vlookup which works (ish). the lookup only picks up the first instance of the...
  • Extract values for earliest/latest times
    I am trying to put together a formula to get the earliest start time, the latest end time from column A for each person in Column B-F without the...
Top