Forum Discussion
Anonymous
6 years agoNot applicable
Select today if not yesterday data source base on availability
Hi, I wanted to schedule my PBI report using a data source with today's date and if today's report is not available yet, I want PBI to choose yesterday's report. Can anyone help? Where do I inser...
- 6 years ago
or if you want to make it a bit more legible:
let temp_ = Excel.Workbook(Web.Contents("https://printersales.com:", [RelativePath="timeReportDaily_" & Date.ToText(Date.From(DateTime.LocalNow()), "YYYYMMDD") & ".xlsx"]), null, true), Source = if temp_ = null then Excel.Workbook(Web.Contents("https://printersales.com:", [RelativePath="timeReportDaily_" & Date.ToText(Date.AddDays(Date.From(DateTime.LocalNow()), -1), "YYYYMMDD") & ".xlsx"]), null, true) else temp_ in #"Source"Please mark the question solved when done and consider giving kudos if posts are helpful.
Cheers
Anonymous
6 years agoNot applicable
I got an error, what could it be?
Expression.Error: The name 'seek_latestFunc' wasn't recognized. Make sure it's spelled correctly.
AlB
6 years agoCommunity Champion
Try adding an @ before the recursive call to the function:
let
seek_latestFunc = (offset) =>
let
temp_ = Excel.Workbook(Web.Contents("https://printersales.com:", [RelativePath="timeReportDaily_" & Date.ToText(Date.AddDays(Date.From(DateTime.LocalNow()), offset), "YYYYMMDD") & ".xlsx"]), null, true),
output = if temp_ = null then @seek_latestFunc(offset - 1) else temp_
in output,
Source = seek_latestFunc(0)
in
#"Source"
Please mark the question solved when done and consider giving kudos if posts are helpful.
Cheers