Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi everyone,
After doing a conditional replace using Table.Replace function of some columns in my table, the data types of all the columns have changed to Any. I would love to be able to re-apply the same data types prior to doing a Table.Replace without manually doing so. I can think of getting a list of the used data types per column but I don't know what function to use.
Proud to be a Super User!
Hi @v-yuta-msft,
I've figured out how to do this. The simple solution is to use Table.Schema function which will return the schema of a table. So entering Table.Schema(TablaName)[TypeName] , I could get a list containing the column data types of the table.
Proud to be a Super User!
Hi danextian,
To achieve your requirement, you can custom a new function named Table.recovertype like below:
Table.recovertype = (t as table) as table => Table.TransformColumnTypes(t,{{"Column1", type Column1_type}, {"Column2", type Column2_type},{},{},{},…………})
Every time when you want to recover data type, you can create a new step and invoke the custom function:
#"Recover Type" = Table.recovertype(#"Previous Step")
You can refer to PBIX file here:
https://www.dropbox.com/s/itmtdl7yybt1w59/For%20danextian.pbix?dl=0
Regards,
Jimmy Tao
Hi @v-yuta-msft
Thanks for the reply but what I am trying to achieve is getting the column data type without actually having to manually input them. Your custom function script indicates the actual column type of each column in the table instead of the custom function itself to detect the data types.
The script is going to be similar with this: Type.TableColumn(tableType as type, column as text) as type
which will loop through all the columns in the table and return a list that contains the actual data type of each column.
Proud to be a Super User!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
99 | |
83 | |
76 | |
66 |
User | Count |
---|---|
120 | |
108 | |
95 | |
83 | |
77 |