I am trying to use a file from SharePoint as a source for a dashboard. An updated version of this file is uploaded to this SharePoint folder every day with an incremented interger suffix at the end (file_name_253, file_name_254, etc).
To ensure I am getting the newest file I calulated the suffix number and applied it to the base file name. The only way I could figure out how to do this was using M. Below is a sample of the few lines that get this done.
FileSuffix = Int32.From(230 + Duration.Days(DateTime.Date(DateTime.LocalNow()) - Date.FromText("6/4/2018"))),
File = Text.Combine({"sharepointlocation/filename_", Text.From(FileSuffix), ".xlsx"}, ""),
Source = Excel.Workbook(Web.Contents(File), null, true),
This code seems to work and when I refresh on the desktop application my report successfully updates with the data from the newest file. However the issue arose when I deployed it to the Power BI Report Server and tried to schedule the refresh. On the Report Server, no data sources are recognized. The Data Source link is greyed out when you go to manage the report.
Same for Desktop Application when you go to the Data Source Settings. It returns with the following message: "We didn't find any data sources in this file."
Is there an issue with my code or a better way to retrieve the most recent file in the directory? Has anyone else experienced a similar issue?