Get the refresh date & time in Power Query

muhammad susanto

Well-known Member
Joined
Jan 8, 2013
Messages
2,088
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
hi all..

how to make the code working well
Excel Formula:
let
//Get the file path
    FilePathString = FilePath,

//Get length of file path
    FilePathLength = Text.Length(FilePathString),

//Get last slash position
LastSlash = Text.PositionOf(FilePathString,"\",Occurrence.Last),

//Get the folder path
FolderPath = Text.Start(FilePathString,LastSlash + 1),

//Get the file name
FileName = Text.End(FilePathString,FilePathLength - LastSlash - 1),

//Get the date modified
    DateModified = Folder.Contents(FolderPath){[Name=FileName]}[Date modified]

in
    DateModified
after running code show message

"Expression.Error: The import FilePath matches no exports. Did you miss a module reference?"

then Go Error
show message:
"Expression.Error: The name 'FilePath' wasn't recognized. Make sure it's spelled correctly"

how to fix the problem? please, give me correct new code

thanks

susant
 
Last edited by a moderator:

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
What is FilePath supposed to be in the first line after the Let? That is not a built-in function.
 
Upvote 0
Hi..
I found the code in google, that's code no syntax error message when pasting into power query editor but after running the code not working properly
 
Upvote 0
Then you missed some code. There must have been another query/function called FilePath that returned the file path for the source workbook.

As an aside, that would actually return the date that one source file was modified, not the last refresh time of your query. Getting the latter is a lot simpler as you can just use DateTime.LocalNow in a query.
 
Upvote 0
hi man, thank you but i really want to use the code like in this video link
but i don't know how to modify the code to make correctly
 
Upvote 0
Did you download the example file? In the video it clearly shows him creating a query called FilePath to return the path of the source file. That is what you are missing.
 
Upvote 0

Forum statistics

Threads
1,223,843
Messages
6,174,982
Members
452,598
Latest member
jeffreyp

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