Quantcast
Channel: All Power Query posts
Viewing all articles
Browse latest Browse all 127827

Re: Refreshing queries with functions doens't work

$
0
0

Hi,

 

Seems I am running into the same hurdle.

 

Any advice on how I could modify my query?

let
    // Calculate the Start of the Month, Today then format the date parameter string as YYYYMMDD.
    MonthStart = Date.StartOfMonth(DateTime.LocalNow()),
    MonthStart_YYYYMMDD = Date.ToText(#date(Date.Year(MonthStart), Date.Month(MonthStart), Date.Day(MonthStart)), "yyyyMMdd"),  
    Today_YYYYMMDD = Date.ToText(#date(Date.Year(DateTime.LocalNow()), Date.Month(DateTime.LocalNow()), Date.Day(DateTime.LocalNow())),"yyyyMMdd"),
    // Store a list of the User ID's from Harvest (Only include the ID's of the people you need visalised on this data set)
    User_IDS = {"1219708","294662","337056"},
    // Intiate the query
    Data = List.Generate(
    ()=> [Counter = 0],
    each [Counter]<List.Count(User_IDS),
    each [Counter=[Counter] + 1],
    each Json.Document(Binary.Buffer(Web.Contents("https://equipmentmanagementsolutions.harvestapp.com/people/" & Text.From(User_IDS{[Counter]}) & "/entries?from=" & MonthStart_YYYYMMDD & "&to=" & Today_YYYYMMDD  ,[Headers=[#"Authorization" = Harvest_Credentials,#"Content-Type"="application/json",#"Accept"="application/json"]])))
    ),
    #"Converted to Table" = Table.FromList(Data, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Expanded Column1" = Table.ExpandListColumn(#"Converted to Table", "Column1"),
    #"Expanded Column2" = Table.ExpandRecordColumn(#"Expanded Column1", "Column1", {"day_entry"}, {"Column1.day_entry"}),
    #"Expanded Column1.day_entry" = Table.ExpandRecordColumn(#"Expanded Column2", "Column1.day_entry", {"id", "notes", "spent_at", "hours", "user_id", "project_id", "task_id", "created_at", "updated_at", "adjustment_record", "timer_started_at", "is_closed", "is_billed", "started-at", "ended-at"}, {"Column1.day_entry.id", "Column1.day_entry.notes", "Column1.day_entry.spent_at", "Column1.day_entry.hours", "Column1.day_entry.user_id", "Column1.day_entry.project_id", "Column1.day_entry.task_id", "Column1.day_entry.created_at", "Column1.day_entry.updated_at", "Column1.day_entry.adjustment_record", "Column1.day_entry.timer_started_at", "Column1.day_entry.is_closed", "Column1.day_entry.is_billed", "Column1.day_entry.started-at", "Column1.day_entry.ended-at"}),
    #"Renamed Columns" = Table.RenameColumns(#"Expanded Column1.day_entry",{{"Column1.day_entry.id", "Entry.ID"}, {"Column1.day_entry.notes", "Entry.Notes"}, {"Column1.day_entry.spent_at", "Entry.Date"}, {"Column1.day_entry.hours", "Hours.OnTask"}, {"Column1.day_entry.user_id", "User.ID"}, {"Column1.day_entry.project_id", "Project.ID"}, {"Column1.day_entry.task_id", "Task.ID"}, {"Column1.day_entry.created_at", "Entry.Created.DateTime"}, {"Column1.day_entry.updated_at", "Entry.Updated.DateTime"}, {"Column1.day_entry.started-at", "Entry.StartTime"}, {"Column1.day_entry.ended-at", "Entry.EndTime"}}),
    #"Removed Columns" = Table.RemoveColumns(#"Renamed Columns",{"Column1.day_entry.timer_started_at"}),
    #"Renamed Columns1" = Table.RenameColumns(#"Removed Columns",{{"Column1.day_entry.is_billed", "Is.Billable"}, {"Column1.day_entry.is_closed", "Entry.IsClosed"}}),
    #"Removed Columns1" = Table.RemoveColumns(#"Renamed Columns1",{"Column1.day_entry.adjustment_record"}),
    #"Merged Queries" = Table.NestedJoin(#"Removed Columns1",{"User.ID"},Harvest_Users,{"Column1.user.id"},"NewColumn",JoinKind.LeftOuter),
    #"Expanded NewColumn" = Table.ExpandTableColumn(#"Merged Queries", "NewColumn", {"Column1.user.first_name", "Column1.user.last_name", "Column1.user.department"}, {"NewColumn.Column1.user.first_name", "NewColumn.Column1.user.last_name", "NewColumn.Column1.user.department"}),
    #"Merged Queries1" = Table.NestedJoin(#"Expanded NewColumn",{"Project.ID"},Harvest_Projects,{"Column1.project.id"},"NewColumn",JoinKind.LeftOuter),
    #"Expanded NewColumn1" = Table.ExpandTableColumn(#"Merged Queries1", "NewColumn", {"Column1.project.client_id", "Column1.project.name", "Column1.project.billable"}, {"NewColumn.Column1.project.client_id", "NewColumn.Column1.project.name", "NewColumn.Column1.project.billable"}),
    #"Merged Queries2" = Table.NestedJoin(#"Expanded NewColumn1",{"NewColumn.Column1.project.client_id"},Harvest_Clients,{"Column1.client.id"},"NewColumn",JoinKind.LeftOuter),
    #"Expanded NewColumn2" = Table.ExpandTableColumn(#"Merged Queries2", "NewColumn", {"Column1.client.name"}, {"NewColumn.Column1.client.name"}),
    #"Merged Queries3" = Table.NestedJoin(#"Expanded NewColumn2",{"Task.ID"},Harvest_Tasks,{"Column1.task.id"},"NewColumn",JoinKind.LeftOuter),
    #"Expanded NewColumn3" = Table.ExpandTableColumn(#"Merged Queries3", "NewColumn", {"Column1.task.name", "Column1.task.billable_by_default"}, {"NewColumn.Column1.task.name", "NewColumn.Column1.task.billable_by_default"}),
    #"Removed Columns2" = Table.RemoveColumns(#"Expanded NewColumn3",{"NewColumn.Column1.project.billable", "Is.Billable", "Entry.IsClosed"})
in
    #"Removed Columns2"

 

 


Viewing all articles
Browse latest Browse all 127827

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>