Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Define and invoke function within query

I am struggling with refreshing data coming off multiple web API’s which I combine using a parameter in the URL. The data refreshes fine in Power BI desktop, but I cannot get it to refresh within the...
  • ImkeF's avatar
    ImkeF
    7 years ago

    That would be done like so:

     

    let
    
    	AssessmentsInfoFunction = (AreaAPI as text) as list =>
    	let
    		Source = Json.Document(Web.Contents(“https://abc.xxx.com”,
    		[
    		RelativePath= “/api/v1/gateway/platform/”&AreaAPI&”/assessmentcriteria”
    		]
    		))
    	in
    		Source,
    
    	Source = {ClientDetails[RootAreaGuid]},
    	#"ListOfLists" = List.Combine(Source),
    	#"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    	#"Renamed Columns" = Table.RenameColumns(#"Converted to Table",{{"Column1", "AreaGuidsForFunction"}}),
    	#"Expanded AreaGuidsForFunction" = Table.ExpandListColumn(#"Renamed Columns", "AreaGuidsForFunction"),
    	#"Added Custom1" = Table.AddColumn(#"Expanded AreaGuidsForFunction", "Custom", each AssessmentsInfoFunction([AreaGuidsForFunction])),
    	#"Merged Queries" = Table.NestedJoin(#"Added Custom1",{"AreaGuidsForFunction"},ClientDetails,{"RootAreaGuid"},"ClientDetails",JoinKind.LeftOuter),
    	#"Expanded ClientDetails" = Table.ExpandTableColumn(#"Merged Queries", "ClientDetails", {"ClientName"}, {"ClientName"})
    in
    	#"Expanded ClientDetails"