Hello,
I would need an assistance with M code.
Namely, excel files are stored on the sharedrive and Power Bi only needs the newest file from the folder (the file with the latest date created). The file names are standardized except the date part: SI Dashboard Data - FY17 - 2017-05-22
The report has set sceduled refresh and each time Power BI should replace the old file with the newest.
I put filters to extract file by SI Dashboard name and by the latest date created.
Here is the M code but it doesn't work when the new file is saved on the drive. I guess some variable for latest date should be introduced but i have no idea how.
Could you please shed a light on this? Highly appreciated.
let
Source = SharePoint.Files("https://dimensiondata-my.sharepoint.com/personal/bojana_sokica_dimensiondata_com/", [ApiVersion = 15]),
#"Filtered by xlsx" = Table.SelectRows(Source, each ([Extension] = ".xlsx")),
#"Filtered by FileName" = Table.SelectRows(#"Filtered by xlsx", each Text.StartsWith([Name], "SI Dashboard")),
#"Filtered by Newest Date" = Table.SelectRows(#"Filtered by FileName", let latest = List.Max(#"Filtered by FileName"[Date created]) in each [Date created] = latest),
#"SI Dashboard - SLA Performance - FY17 - 2017-05-22-07-20-04 xlsx_https://dimensiondata-my sharepoint com/personal/bojana_sokica_dimensiondata_com/Documents/data/" = #"Filtered by Newest Date"{[Name="SI Dashboard - SLA Performance - FY17 - 2017-05-22-07-20-04.xlsx",#"Folder Path"="https://dimensiondata-my.sharepoint.com/personal/bojana_sokica_dimensiondata_com/Documents/data/"]}[Content],
#"Imported Excel" = Excel.Workbook(#"SI Dashboard - SLA Performance - FY17 - 2017-05-22-07-20-04 xlsx_https://dimensiondata-my sharepoint com/personal/bojana_sokica_dimensiondata_com/Documents/data/"),
Detail_Sheet = #"Imported Excel"{[Item="Detail",Kind="Sheet"]}[Data]
in
Detail_Sheet