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

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.

Reply
Anonymous
Not applicable

Power Query Loaded Table - Change Data type through VBA

I have tables loaded on my Excel from Power Query. Some columns do not retain the data type and format I have specified in power query. For Example: Percentage type changes to Decimal(87.82%>0.878236484) and date type changes to Number(1/1/2020>43831) I hope to write VBA code to change the column data type by specifying the table name and column field header.

 

Kindly help with this.

 

Thank you.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hello, @Jimmy801  Thank you for taking the time to reply to my question. Yes, i understand we would need to format the data type back on excel. I just wanted to automate that with VBA. I found the code to do that.

 

Thank you.

View solution in original post

2 REPLIES 2
Jimmy801
Community Champion
Community Champion

Hello @Anonymous 

 

Power Query is loading the raw data to Excel. For a date this means a number and percentage is 0,xx. So the only way is to reformat your data in Excel once again. Don't forget to change the settings to keep changes of your format. So you don't need to write a VBA as long your column settings does change frequently.


If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

Anonymous
Not applicable

Hello, @Jimmy801  Thank you for taking the time to reply to my question. Yes, i understand we would need to format the data type back on excel. I just wanted to automate that with VBA. I found the code to do that.

 

Thank you.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors