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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Lexx
Advocate I
Advocate I

after running R script power query is wrongly changing type of column

After I run an R script in Power Query one of my columns (which is text type and should stay that way) gets changed to number.

How do I stop Power Query or Power Bi from doing this?

 

Thanks

2 REPLIES 2
Mila123
Frequent Visitor

I'm not sure what I've done but suddenly when I clicked on Transform File under Transform File from Query there was this statement where I could change type from Int64.Type to type Text. That is the moment where the data were prevously corrupted.

 

Here is the statement for reference if someone would need it:

 

= (Parameter2 as binary) => let
Source = Excel.Workbook(Parameter2, null, true),
Tabela2_Table = Source{[Item="Table2",Kind="Table"]}[Data],
#"Changed Type" = Table.TransformColumnTypes(Tabela2_Table,{{"NAME ", type text}, {"SURNAME", type text}, {"DATE OF BIRTH", type date}, {"WORKING PERIOD BEFORE", type text}})
in
#"Changed Type"

Mila123
Frequent Visitor

I have the same issue while importing excel file from Sharepoint. The column in excel is text type and content is predefined as yymmdd (working period before employed in our company). After importing PowerQuery automatically changes text to number and I get useless data. Probably solution could be if we enter data in excel in this form: '000510 but users could forget about that and issue would arrize again.

Is there any option to prevent PowerQuery from changing data type or force a type before data are corrupted?

I would really appreciate any feedback.

Regards,

Mila

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.