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
wwyws0000
Regular 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 1
wdx223_Daniel
Super User
Super User

Date.ToText(AsOfDate,"yyyyMMdd")

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.

Top Solution Authors
Top Kudoed Authors