Skip to main content

Power BI

New

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

Vote (6) 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

5419777e dfcf-ea11-a812-000d3a579c38 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

5419777e dfcf-ea11-a812-000d3a579c38 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

a3309361 99be-ea11-a812-000d3a8ddfb2 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

5a09c956 9d3e-4112-9039-492d22b24fa0 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.