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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
JackEwans
Regular Visitor

Data Refresh Issue - help please!

Hi All, 

I've created a custom function (shown at the bottom of this message) in Power BI Desktop which uses the Google geocoding API to calculate latitude and longitude for a provided address.

 

I've then created a custom column to invoke this function for the address field in every row of the address table of a membership database:

=fngeocode(([addPostCode])


The issue I'm having is that that this membership database is live and is being added to every day with new sign ups and to import and geocode these new membership addresses I need to refresh the data in Power BI: this causes the custom column to re-invoke the custom function for every row in the address tables (even for rows that have already been geocoded).

As the address table is around 25,000 rows long, this results in that number of requests to the Google Geocoding API every time I want to refresh the data or even make slight modifications to the query: something that takes both a significant period of time and means that I'm going far above the free limits to google's API service.

What I want is to only invoke the custom function for new rows that haven't yet been geocoded (i.e. where the latitude and longitude columns are blank) but I don't know how to achieve this. Does anyone have any ideas?

My only thoughts were to change the custom column code to only invoke the function on blank (not yet geocoded cells) but I don't know whether this is possible since it would involve circular references.

As I say, any help or advice on this would be very much appreciated! 

For reference, here's my custom function code:

 

let
    getgeo = (postcodeb as text) =>
let
    Source = Json.Document(Web.Contents("https://maps.googleapis.com/maps/api/geocode/json?address="&postcodeb&",UK&key=MYKEY")),
    results = Source[results],
    results1 = results{0},
    geometry = results1[geometry],
    location = geometry[location],
    #"Converted to Table" = Record.ToTable(location),
    #"Transposed Table" = Table.Transpose(#"Converted to Table"),
    #"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table", [PromoteAllScalars=true]),
    TestForError = try #"Promoted Headers",
    Output = if TestForError[HasError] then null else #"Promoted Headers"
in
    Output
in
    getgeo

 

0 REPLIES 0

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors