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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
RickHantz
New Member

"How to prevent Power BI from converting text data?"

We have data with lots of product codes that get auto converted to dates or scientific notation.

To prevent the conversion, we import the csv files as text to excel and save as xlsm.

However, Power BI still auto converts them into nonsense.

Are we missing a setting or technique to prevent the auto conversion?

 

thanks,

 

RickH

1 ACCEPTED SOLUTION
wonga
Continued Contributor
Continued Contributor

@RickHantz, try disabling the two highlighted items in below image:

 

pic.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Otherwise, try the following:

 

When you load data into Power BI Desktop instead of clicking "Load", click "Edit" instead (which opens the Query Editor) and remove all steps after the "Source" or "Navigation" step (depending on if it's Excel or CSV, since Excel can have multiple sheets ,"Navigation" would be required to select the appropriate sheet whereas CSV's are only one sheet). By doing this, you will retain the source data without any modifications being done by Power BI automatically.

 

View solution in original post

10 REPLIES 10
Anonymous
Not applicable

I know this is from years ago, but just adding an alternate solution.

 

Rather than trying to prevent PowerBI from changing the type, let it change it as per default. Then go into Query Editor, and change the type for the one column for which you wish to change the type. It is probably easier to add this one step rather than to manually set the data type for multiple columns.

 

If you want to "intercept" this when you're first loading the data, click on "Transform data" to go straight to the Query Editor before the data gets loaded.

CahabaData
Memorable Member
Memorable Member

wonga
Continued Contributor
Continued Contributor

@RickHantz I don't have access to Power BI right now, but isn't there an option under File -> Options -> Options -> Data Load about performing implicit transformations when loading data into Power BI?

 

I know there was an option about auto detecting relationships, there should be something similar for transformations.

There is one to turn off auto date conversions, but not for EE.

wonga
Continued Contributor
Continued Contributor

@RickHantz, try disabling the two highlighted items in below image:

 

pic.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Otherwise, try the following:

 

When you load data into Power BI Desktop instead of clicking "Load", click "Edit" instead (which opens the Query Editor) and remove all steps after the "Source" or "Navigation" step (depending on if it's Excel or CSV, since Excel can have multiple sheets ,"Navigation" would be required to select the appropriate sheet whereas CSV's are only one sheet). By doing this, you will retain the source data without any modifications being done by Power BI automatically.

 

That seems to work, but now I need to manually specify row1 is the header row. How do I do that?

Editing the query lets me specify the two non-text columns as number, but I don't see how to specify the header row.

 

thanks for the help,

 

-RickH

Ok, I manually specified the header row, that works.

Then I edited the query for the two columns that have integers in them from text to number.

I now get an error saying it can't convert from text to number. We need to be able to sum those columns.

wonga
Continued Contributor
Continued Contributor

@RickHantz

 

Can you provide some sample data, specifically what you start out with and what you want to end up with?

 

If the value you have in text form is just a bunch of numbers (digits), then there shouldn't be a reason as to why the conversion would fail.

 

CahabaData
Memorable Member
Memorable Member

since you say Date or Scientific Notation : I am wondering when you look at the table data view's field type - what is it saying?

 

also in Query Editor;  if the field type is not saying 'text' - and you change it to text - does the display correct itself?

 

www.CahabaData.com

No, once its converted from text to a date or number, the original data is lost.

Opening the spreadsheet in Power BI converts it; it’s too late to change the column types.

 

(In the news, the gene research community has been bit by this Excel auto conversion, corrupting data published as Excel spreadsheets.)

 

I was thinking of adding an apostrophe by macro to all the data in columns that are affected. Going to try that next.

 

-RickH

 

 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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