Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
I have a query setup to invoke a custom function that uses the Bing Maps API call to retrieve the distance and drive time to a list of addresses. My data set currently only has 500 rows so the function gets used 500 times everytime I refresh the data. This takes about 15 minutes for the query to run through the 500 rows.
My question, is there anyway to commit the distance and drive time data into the query so that the next time I refresh the data it sees that it already retrieved that data and to ignore it this time around? I really would only want the custom function call to run with newly added rows of data and to ignore all the existing rows.
I was thinking worst case, all the data is saved in an Excel file, so after I ran the funtion the frist time, I could manually commit the API data back into the orginal Excel file and setup a second query that only runs if the data is missing. I would prefer not to have to manually commit the data into the Excel file. Maybe the answer is to somehow automate it to update the Excel file? If that seems to make sense to anyone, any advice on how to commit that data back?
Solved! Go to Solution.
I used the following video to create an R Visual that exports the Excel file and overwrites the orginal. One query is used for the main dashboard. A second query creates the duplicate Excel file that gets exported out after the API call is finished.
Power BI - Write Data to Excel (On Multiple Tabs) - Bing video
library(openxlsx)
dataset2 = dataset[,c("Name","Address","Notes","Website","TravelDistance","TravelDuration","TravelDurationTraffic","Latitude","Longitude")]
tabs = list("Sheet 1" = dataset2)
hs = createStyle(fontSize=11, fontColour="#000000",halign="center",fgFill="#CCCCCC")
if(dataset$Selection[1]=="Write") {
write.xlsx(tabs, file ="C:/Users/User/Data/Data.xlsx", colWidths = "12", headerStyle = hs)
openXL(file = "C:/Users/User/Data/Data.xlsx") }
plot(1,1)
I used the following video to create an R Visual that exports the Excel file and overwrites the orginal. One query is used for the main dashboard. A second query creates the duplicate Excel file that gets exported out after the API call is finished.
Power BI - Write Data to Excel (On Multiple Tabs) - Bing video
library(openxlsx)
dataset2 = dataset[,c("Name","Address","Notes","Website","TravelDistance","TravelDuration","TravelDurationTraffic","Latitude","Longitude")]
tabs = list("Sheet 1" = dataset2)
hs = createStyle(fontSize=11, fontColour="#000000",halign="center",fgFill="#CCCCCC")
if(dataset$Selection[1]=="Write") {
write.xlsx(tabs, file ="C:/Users/User/Data/Data.xlsx", colWidths = "12", headerStyle = hs)
openXL(file = "C:/Users/User/Data/Data.xlsx") }
plot(1,1)
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
87 | |
81 | |
53 | |
37 | |
35 |