Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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
Solved! Go to Solution.
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})
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-...
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