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
lekkerbek
Helper IV
Helper IV

Import zeros from Excel

I have an Excel file which shows 0 before the actual number. For example

 

000280

 

* When I change the data type (in Excel) to "text" the 000 disappear.

* When I leave it as is and try to import it, it also eliminates the 000. When I remove the automatic "change type" in the query editor it remains the figure without the 000. 

 

So the normal solution would be to change the column type to text, but that doesn't work here either.

 

Anybody have a solution?

 

1 ACCEPTED SOLUTION

@lekkerbek If you set the format of the column/worksheet to text first, then import/copy-paste the values the "00's" should stay... Give that a shot, but in my experience that works.


Looking for more Power BI tips, tricks & tools? Check out PowerBI.tips the site I co-own with Mike Carlo. Also, if you are near SE WI? Join our PUG Milwaukee Brew City PUG

View solution in original post

6 REPLIES 6
v-haibl-msft
Employee
Employee

@lekkerbek

 

If I change the data type (in Excel) to “Text”, the 000 will persist.

Import zeros from Excel_1.jpg

 

Then import it to Power BI, go to the “Navigation” step, the column data type will be Any and the 000 will also persist.

I’m using Excel 2016 and latest PBI Version: 2.38.4491.282 64-bit (August 2016)

Import zeros from Excel_2.jpg

 

Best Regards,

Herbert

Thanks for all your suggestions. Normally the "convert to text" works, but somehow with this dataset it doesn't.

 

The copy/paste to a new table actually works, but is time consuming as it doesn't accept all lines in one copy/paste "session".

 

I'm able to export to XML and when I import that it works, so I'm guessing that's the way to go.

@lekkerbek

 

If you can get your problem solved by exporting to XML then importing, you can mark your last post as solution to close this thread.

 

Best Regards,

Herbert

I would consider this as a workaround and not so much as a solution.

 

I mark the copy/paste suggestion as the accepted solution.

Framet
Resolver II
Resolver II

Hi There,

 

In theory you need to edit the query and tell it the data type that you want as when you first load the excel file Power BI will be attempting to establish the best data type for each column and subsequently removing your 0's and converting to an integer.

 

The odd thing is that if you remove the change type step the data should still have leading 0's and in the small test below this was the case. I know you mentioned doing both seperately but have you tried both setting the column to text in excel and removing the change type or amending it as below? I imagine you do need it as type text to avoid excel stripping the leading zero's on saving the file.

 

For example:

 

This simple excel table loaded into Power BI:

ID is general format, REF is text.

IDREF
1000125
2000144
3000887
4000889
5000482

 

If you edit the query last step applied to the data "Changed Type":
= Table.TransformColumnTypes(#"Promoted Headers",{{"ID", Int64.Type}, {"REF", Int64.Type}})

 

You can simply change this manually to:

= Table.TransformColumnTypes(#"Promoted Headers",{{"ID", Int64.Type}, {"REF", type text}})

 

Or right click the column you don't like the data type on and choose "Change Type" -> Text.

 

Power BI will then retain your leading zero's. Or at least did for me.

 

Hope this is of some help.

 

Thomas

@lekkerbek If you set the format of the column/worksheet to text first, then import/copy-paste the values the "00's" should stay... Give that a shot, but in my experience that works.


Looking for more Power BI tips, tricks & tools? Check out PowerBI.tips the site I co-own with Mike Carlo. Also, if you are near SE WI? Join our PUG Milwaukee Brew City PUG

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.