# Adding or deleting a column from source file in power query



## srehman (Apr 27, 2020)

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.


----------



## GraH (Apr 27, 2020)

Hello,

1. In the source step you'd have something like 

```
= 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.


----------



## srehman (Apr 27, 2020)

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},


----------



## GraH (Apr 28, 2020)

Hi, look at the invoked custom function.


----------



## srehman (Apr 28, 2020)

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


----------



## GraH (Apr 28, 2020)

Can you please look in the source step of the first attachment.


----------



## srehman (Apr 28, 2020)

there is no Column things as you mentioned


----------



## GraH (Apr 28, 2020)

*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?


----------

