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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Frixel
Post Prodigy
Post Prodigy

How to get create file date in query

Hello,

 

How and when can I get the created date of a file in my query?
If I have a query multiple files in a folder that I combine with the function combine files how can I afterwards get the creation date of the files in my query.
This date is not in the files themselves.

 

1 ACCEPTED SOLUTION

Hi @Frixel 


You need to select the combined file in the left tab then check 'Removed columns' step in the right tab

Did it work ? 👌 Mark it as a solution to help spreading knowledge 👉 A kudos would be appreciated

View solution in original post

10 REPLIES 10
DataVitalizer
Super User
Super User

Hi @Frixel 
Are you willing to retrieve the created date of each file from your folder into one column in the combined file?

 

Did it work ?  👌 Mark it as a solution to help spreading knowledge  👉 A kudos would be appreciated

@DataVitalizer 

 

Yes, that is what i want.

@Frixel try following these steps

  1. Connect the folder
  2. Combine and transform
  3. From the step's settings tab in the right side of your screen click on the gear of Removed columns' step
  4. Check Created date

Go back to last step of step's settings tab and check your data once again

 

Did it work ?  👌 Mark it as a solution to help spreading knowledge 👍 A kudos would be appreciated

Hi @DataVitalizer 

 

I found what yoy mean and in the desktop it is okay, but when i publish in the portal and there is a refrech/update because there is a new file in the folder it goes wrong.

 

This is what i do.

Frixel_0-1634280731362.png

Then i get this colomn:

Frixel_1-1634281365006.png

 

If i then go to last step of step's settings tab i see this:

Frixel_2-1634281488136.png

 

i change the colomn name to:

Frixel_3-1634281565383.png

 

When i refresh in the Desktop there is NO issue.

Then i save and publisch to portal service and there is a update(new file in folder) then i get after long waiting this error:

Error in datasource:Expression.Error: <pii>The column '11-10-2021 12:10:18' of the table wasn't found.</pii>. <pii>11-10-2021 12:10:18</pii>. . The exception was raised by the IDbCommand interface. Table: ExportFile.

 

 

What do i wrong?

Hi @DataVitalizer 

 

Where is step 3 (the settings tab) what you mean?

 

Frixel_0-1633637808140.png

 

Hi @Frixel 


You need to select the combined file in the left tab then check 'Removed columns' step in the right tab

Did it work ? 👌 Mark it as a solution to help spreading knowledge 👉 A kudos would be appreciated

Frixel
Post Prodigy
Post Prodigy

@amitchandak 

 

I think you don`t understand me.

Each file in the folder does not have a datestamp in a colomn in the file.

For my report i have combine all that files and every day when there is a new file. In my report i will to filter on a specific day so i see only the report from that day. 

But i have no colomn to filter on that in the 'Fields' and i have also not a 'Field'  with the source name.

Hi,

I was facing the same issue and after some research the solution was quite straight forward.

What you need to do is after expanding your files just delete the step where it removed columns it should be just above expanded columns step and you will get all the feilds you had before expanding select the creation date or any other feild yo need and delete the rest of them.

Please mark as solved if it works for you.

@Frixel , I tried another way. I modified the code and added file created date

 

check step - #"Removed Other Columns1" = Table.SelectColumns(#"Renamed Columns1", {"Source.Name", "Transform File","Date created"}),

 

 

let
    Source = Folder.Files("C:\Users\Amit.Chandak\Google Drive\Kanerika\power bi\Data\csv\combine"),
    #"Filtered Hidden Files1" = Table.SelectRows(Source, each [Attributes]?[Hidden]? <> true),
    #"Invoke Custom Function1" = Table.AddColumn(#"Filtered Hidden Files1", "Transform File", each #"Transform File"([Content])),
    #"Renamed Columns1" = Table.RenameColumns(#"Invoke Custom Function1", {"Name", "Source.Name"}),
    #"Removed Other Columns1" = Table.SelectColumns(#"Renamed Columns1", {"Source.Name", "Transform File","Date created"}),
    #"Expanded Table Column1" = Table.ExpandTableColumn(#"Removed Other Columns1", "Transform File", Table.ColumnNames(#"Transform File"(#"Sample File"))),
    #"Changed Type" = Table.TransformColumnTypes(#"Expanded Table Column1",{{"Source.Name", type text}, {"Item Id", Int64.Type}, {"Name", type text}, {"Brand Id", Int64.Type}, {"Category Id", Int64.Type}, {"Sub Category Id", Int64.Type}, {"Brand", type text}, {"Category", type text}, {"Sub Category", type text}})
in
    #"Changed Type"

 

 

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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