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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

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
Fabric Data Days is here Carousel

Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.