Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

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...
  • AlB's avatar
    AlB
    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