Forum Discussion
wwyws0000
3 years agoRegular Visitor
Dynamic file path based on a date parameter in the report
Hi,
I have a date parameter called "AsOfDate" in the report in the form of "mm/dd/YYYY" (e.g. 12/15/2022) that the user can edit. I'm trying use this as part of a dynamic file path for reading in csv files. For example, filename_20221215. How do I convert the "AsOfDate" paramter into a text form of YYYYmmdd in the power query?
My attempt is:
Csv.Document(File.Contents("MY_FILE_PATH\FILE_NAME_" & Date.ToText(AsOfDate,[Format = "YYYYmmdd"]) & ".csv"),[Delimiter=",", Columns=18, Encoding=1252, QuoteStyle=QuoteStyle.None])
But I got an error saying:
Parameter.Error: We couldn't convert the text value to date using the specified format. The format includes a time component.
Details:
Format=YYYYmmdd
Edit: Figured it out that I just neeed to change "YYYYmmdd" to "YYYYMMDD"
Thank you for all the help in advance.
1 Reply
- wdx223_DanielCommunity Champion
Date.ToText(AsOfDate,"yyyyMMdd")