Forum Discussion

sinanalmac's avatar
sinanalmac
Resolver I
4 years ago
Solved

Get Data from SharePoint Folder with Today's Date

Hi All I need PowerQuery to go every day and  get  file that is stored in a sharepoint folder with today's date.   Explanation:   Our raw data (the one we feed to PowerQuery) are stored to our...
  • sinanalmac's avatar
    4 years ago

    Hİ  ,all  I solved The problem. 

    I changed some  M Language  in advanced Editor like this

    let
        Source = SharePoint.Files("https://unilever.sharepoint.com/sites/DaliyDisputeReport/", [ApiVersion = 15]),
        #"Daily-Dispute-Report_14 06 2022 xls_https://brbsapp266 sharepoint com/sites/DaliyDisputeReport/Shared Documents/General/" = Source{[Name="Daily-Dispute-Report_"&Date.ToText(Date.AddDays(DateTime.Date(DateTime.LocalNow()),-1),"dd.MM.yyyy")&".xls",#"Folder Path"="https://brbsapp266.sharepoint.com/sites/DaliyDisputeReport/Shared Documents/General/"]}[Content],
        #"Imported Excel Workbook" = Excel.Workbook(#"Daily-Dispute-Report_14 06 2022 xls_https://brbsapp266 sharepoint com/sites/DaliyDisputeReport/Shared Documents/General/"),
        #"Crm List_Sheet" = #"Imported Excel Workbook"{[Item="Crm List",Kind="Sheet"]}[Data],
        #"Promoted Headers" = Table.PromoteHeaders(#"Crm List_Sheet", [PromoteAllScalars=true])
        
    in
     

     

    Thank you 

  • BA_Pete's avatar
    4 years ago

    Hi sinanalmac ,

     

    Connect to your SharePoint folder using the SharePoint Folder connector.

    When the files list comes up in the connection dialog, hit the Transform button. This should give you a list of all files available from that folder, something like this:

     

    Filter this table as you would a normal table, using a combination of filters on [Name], [Date modified], and [Date created]  to create a generic set of filters that will always select 'today's' file from your folder.

     

    For example, your filter arguments may look something like this:

    Table.SelectRows(
        previousStepName,
        each Text.StartsWith([Name], "DailyDispute")
            and [Date created] = Date.From(DateTime.LocalNow())
    )

     

    Once you've narrowed your table down to the one report for today, click the yellow "Binary" word in the [Content] column to open up that file in your query.

     

    Pete