Skip to main content

Power BI

Needs Votes

Add column - Index column, i.e. Table.AddIndexColumn, shall create whole numbers (int) instead of decimal numbers (float)

Vote (7) Share
Pär Adeen's profile image

Pär Adeen on 16 Sep 2019 14:37:38

Currently the Table.AddIndexColumn () functions creates values of type decimal (floats). I see no reason for creating decimal numbers since the incremental steps can't be set to decimal number, nor the initial value can be set to a decimal value:

Table.AddIndexColumn(table as table, newColumnName as text, optional initialValue as nullable number, optional increment as nullable number) as table

The documentation does not say what type the new column will have, but now it's created as decimal number.

The recommendation will be that Microsoft either changes the type of the generated column, or extends the parameter set with a type so we can define the type as integers (int64) instead

As there can't be anu reason for the index column to have float values, this is likely to be considered as an bug

Comments (4)
Pär Adeen's profile image Profile Picture

Pär Adeen on 10 Sep 2020 20:14:30

RE: Add column - Index column, i.e. Table.AddIndexColumn, shall create whole numbers (int) instead of decimal numbers (float)

As this is now implemented you can mark this with Implemented ;-)
Thanks a lot for helping out

Pär Adeen's profile image Profile Picture

Pär Adeen on 11 Aug 2020 16:10:22

RE: Add column - Index column, i.e. Table.AddIndexColumn, shall create whole numbers (int) instead of decimal numbers (float)

I can see that Power BI Ideas Admin has positive comments on this, although I can't see any actions. Maybe this ha been forgotten

Pär Adeen's profile image Profile Picture

Power BI Ideas Admin on 06 Jul 2020 00:01:40

RE: Add column - Index column, i.e. Table.AddIndexColumn, shall create whole numbers (int) instead of decimal numbers (float)

This should absolutely be an integer number, we are unable to generate specifically needed indexes with float.

Pär Adeen's profile image Profile Picture

Kenneth Barber on 06 Jul 2020 00:01:14

RE: Add column - Index column, i.e. Table.AddIndexColumn, shall create whole numbers (int) instead of decimal numbers (float)

I feel that Table.AddIndexColumn, by default, should use the smallest integer type that it needs to creates all of the indexes. For example, if your table has only 100 rows, then Int8.Type would be used and not Int64.Type.