Adding or deleting a column from source file in power query

srehman

Board Regular
Joined
Jan 4, 2020
Messages
210
Office Version
  1. 2016
Platform
  1. Windows
Hi Team,
We have source csv file in which one Date Time was in a single column.
Now in new update both are separated in 2 separate column Date column & Time column. In addition to that we have 1 more new column user name. Which was not in old csv file.
I am facing expression error. Do want to redo do it again.
Pls provide simple solution
Thanks in advance.
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Hello,

1. In the source step you'd have something like
Code:
= Csv.Document(File.Contents("File.CSV"),[Delimiter=",", Columns=10, Encoding=1252, QuoteStyle=QuoteStyle.None])
Delete the part that says ", Columns=10", that way no matter how many columns there are, they all get loaded.

2. The expression error is likely to be due to the step "Change Type". Either change that step so your columns get the correct data type definition or delete it. That will set all columns to "variant" type. Depending on the steps that follow that might cause other problems.
 
Upvote 0
I am exporting from folder as csv file could not found Column=???

Source = Folder.Files("C:\Users\Rehmans\Desktop\test"),
#"Removed Other Columns" = Table.SelectColumns(Source,{"Content"}),
#"Filtered Hidden Files1" = Table.SelectRows(#"Removed Other Columns", each [Attributes]?[Hidden]? <> true),
#"Invoke Custom Function1" = Table.AddColumn(#"Filtered Hidden Files1", "Transform File from test", each #"Transform File from test"([Content])),
#"Removed Other Columns1" = Table.SelectColumns(#"Invoke Custom Function1", {"Transform File from test"}),
#"Expanded Table Column1" = Table.ExpandTableColumn(#"Removed Other Columns1", "Transform File from test", Table.ColumnNames(#"Transform File from test"(#"Sample File"))),
#"Changed Type" = Table.TransformColumnTypes(#"Expanded Table Column1",{{"Site ID", type text}, {"Client ID", type text}, {"SKU", Int64.Type}, {"Date Time", type datetime},
 
Upvote 0
Hi, look at the invoked custom function.
1588057577813.png
 
Upvote 0
Thanks for your's prompt responses. I am trying my best to achieve results but unfortunately no luck . I did with source csv file from a folder no such option as you mentioned above. i am sending you snapshots.

Please advise. thanks
 

Attachments

  • Query1.PNG
    Query1.PNG
    112.2 KB · Views: 63
  • Query2.PNG
    Query2.PNG
    53.4 KB · Views: 64
  • Query 3.PNG
    Query 3.PNG
    51.7 KB · Views: 56
Upvote 0
Can you please look in the source step of the first attachment.
 
Upvote 0
there is no Column things as you mentioned
 

Attachments

  • q5.PNG
    q5.PNG
    71.2 KB · Views: 39
Upvote 0
srehman, that's a different query then the one I was referring too.
using your screenshot, talking about this one. What's in the source step?
1588080074770.png
 
Upvote 0

Forum statistics

Threads
1,223,793
Messages
6,174,635
Members
452,575
Latest member
Fstick546

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top