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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
rsderby68
Resolver I
Resolver I

Power BI: How to generate a table of daily web traffic reports? Help?

I pull data from a digital site via an API into Power BI for reporting.  The API has an analytics endpoint for a web traffic report, but it is ONLY an aggregate report, as in it won't make one call and separate it into individual days.  I can call (below) to show the traffic for any particular day.  I would like to write a query to use this API call to generate a table where each row is the traffic for a day starting at 2022-05-15 until whatever the current day is.  So a row for 05-15, 05-16, 05-18, until the current date.  

 

Anyone have a suggestion?  

 

https://api.somewhere.tv/analytics?type=traffic&from=2022-05-15&to=2022-05-15

1 ACCEPTED SOLUTION
ppm1
Solution Sage
Solution Sage

Here's one way to do it in the query editor.  To see how it works, just create a blank query, open the Advanced Editor and replace the text there with the M code below.

 

let
    StartDate = #date(2022,5,15),
    EndDate = Date.From(DateTime.LocalNow()),
    DateList = List.Dates(StartDate, Duration.TotalDays(EndDate - StartDate) + 1, #duration(1,0,0,0)),
    Custom1 = List.Transform(DateList, each Date.ToText(_, "yyyy-MM-dd")),
    #"Converted to Table" = Table.FromList(Custom1, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Renamed Columns" = Table.RenameColumns(#"Converted to Table",{{"Column1", "DateAsText"}}),
    #"Changed Type" = Table.TransformColumnTypes(#"Renamed Columns",{{"DateAsText", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "WebCall", each Web.Contents("https://api.somewhere.tv/analytics?type=traffic&from=" & [DateAsText] & "&to=" &  [DateAsText]))
in
    #"Added Custom"

 

Pat

 

Microsoft Employee

View solution in original post

2 REPLIES 2
ppm1
Solution Sage
Solution Sage

Here's one way to do it in the query editor.  To see how it works, just create a blank query, open the Advanced Editor and replace the text there with the M code below.

 

let
    StartDate = #date(2022,5,15),
    EndDate = Date.From(DateTime.LocalNow()),
    DateList = List.Dates(StartDate, Duration.TotalDays(EndDate - StartDate) + 1, #duration(1,0,0,0)),
    Custom1 = List.Transform(DateList, each Date.ToText(_, "yyyy-MM-dd")),
    #"Converted to Table" = Table.FromList(Custom1, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Renamed Columns" = Table.RenameColumns(#"Converted to Table",{{"Column1", "DateAsText"}}),
    #"Changed Type" = Table.TransformColumnTypes(#"Renamed Columns",{{"DateAsText", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "WebCall", each Web.Contents("https://api.somewhere.tv/analytics?type=traffic&from=" & [DateAsText] & "&to=" &  [DateAsText]))
in
    #"Added Custom"

 

Pat

 

Microsoft Employee

Pat, did I mention you are my favorite person?  Thanks! 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.