Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
pade
Advocate III
Advocate III

Why does Table.AddIndexColumn create a decimal number (float) and not a whole number (int)

Anyone that knows why the Add Index Column command "Table.AddIndexColumn" generates numbers with the data type of float and not integer. Also, how can I cast to an integer value inline with the Table.AddIndexColumn command

1 ACCEPTED SOLUTION
AnkitBI
Solution Sage
Solution Sage

Based on my understanding, answer to First question will be it as per design. As return type of Table.AddIndexColumn type is a 'Table', so Index column datatype is not in our control.

 

Regarding Second question, as Table.AddIndexColumn retuns a table, so generic function is required to change the column data type in output table.

 

= Table.TransformColumnTypes(Table.AddIndexColumn(#"Changed Type", "Index", 1, 1),{"Index",Int64.Type})

View solution in original post

6 REPLIES 6
pade
Advocate III
Advocate III

I have now reported this an the idea page for data preparations, please give it a vote: https://ideas.powerbi.com/forums/265200-power-bi-ideas/suggestions/38606662-add-column-index-column-...

AnkitBI
Solution Sage
Solution Sage

Based on my understanding, answer to First question will be it as per design. As return type of Table.AddIndexColumn type is a 'Table', so Index column datatype is not in our control.

 

Regarding Second question, as Table.AddIndexColumn retuns a table, so generic function is required to change the column data type in output table.

 

= Table.TransformColumnTypes(Table.AddIndexColumn(#"Changed Type", "Index", 1, 1),{"Index",Int64.Type})

Thanks @AnkitBI. So there will still be a two step operation needed, just to make sure that the new column has the correct data types, this since I guess that the inner function "Table.AddIndexColumn" will be create as a whole and then been re-written or casted to int64 by the outer function. Im trying to find an efficient OLTP-->OLAP transformation and it was a surprice for me that the index function created a float value since I can't imagine whay anyone would like to have indexes as floats

Hi @pade - Your Assumption is correct, Inner will return entire table and outer Table.Transform will change data type of Index Column.

 

Regarding Index as Float, this was new to me too :). 

 

Thanks

Ankit Jain

Do Mark it as solution if the response resolved your problem. Do like the response if it seems good and helpful.

So is there a "idea" required to be registered for this? I personally can't see the whole consequences for this, but I could imagine that it for e.g. a large dimension and/or a fact table will have some consequences where it comes to resource usage

Nathaniel_C
Community Champion
Community Champion

Hi @pade ,

 

See if @ImkeF has an answer. She is amazing with M.

 

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.