Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

URL based date dependent data request from server - M-script/Query

Does anyone know how to fix this code so it receives data.

 

let
    Now = DateTime.LocalNow(),
    Yesterday = Date.AddDays(Now, -1),
    Date = DateTime.ToText(Yesterday, "dd-MM-yyyy hh:mm") ,   
    Date2 = DateTime.ToText(Now, "dd-MM-yyyy hh:mm"),

Terms = #table({"Dato1","Dato2"},
{{(Uri.BuildQueryString(Date)), (Uri.BuildQueryString(Date2))}}),
SearchSuccessful = (Dato1,Dato2) =>
    let
        Source = 
         Csv.Document(
           Web.Contents(
             "http://Yoursite.com/data/glovadata/search/csv?", 
             [Query=[StartTimeLocal=Dato1]&[EndTimeLocal=Dato2]]
            ),[Delimiter=";", Columns=23, Encoding=1252, QuoteStyle=QuoteStyle.None]
           ),
        Success = Source[success]
    in
	Success,

     Output = Table.AddColumn(
       Terms, 
       "Search Successful", 
       each SearchSuccessful([Dato1],[Dato2])
      )
    
in
    Output

At the moment I get 3 columns with (Error) inside.

The Idea is to send an URL: "http://Yoursite.com/data/glovadata/search/csv?StartTimeLocal=08-04-2019%2002%3A12&EndTimeLocal=09-04..."

 

If the url link generated is not the same as above (with changeable date (last 24 hr data) ), then no data will be received. As the the database requires date to output data. 

The reason I use the shows method is so the data is updateable in powerbi.com

see link for reason: https://blog.crossjoin.co.uk/2016/08/23/web-contents-m-functions-and-dataset-refresh-errors-in-power...

20 REPLIES 20

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors