Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hey PowerBI,
I'd like to conduct a mass look up of all IP addresses within my file providing them with associated latitudes and longitudes so I can accurately locate where they map out to. I have around 3900 distinct Ip addresses altogether. I then need to hook this up to my masterfile which contains various details about users etc.
Ideally I'd like to use the maxmind API to get "Country", "City", "longitude", "latitude" and "is_proxy" data. I know of a previous solution posted by @GilbertQ however since then, that site has since been deprecated. The data from that also doesn't suit my own purposes.
I know this is doable, but just lack the knowledge in M to do this!
https://www.maxmind.com/en/geoip2-precision-services
Many thanks
Hi @GilbertQ,
Thanks for the wonderful post. The problem I am facing when trying to implement is, access restriction when trying to use freegioip.net. When I further researched I found that their address has been changed to ipstack.com
How should we design for this particular website? they changed the plan and not sure how to do that.
Thanks,
Indhu
Hi @indhu
It appears that they have got a free option which has got 10 000 lookups.
Otherwise you would have to pay for a lookup service?
@GilbertQ 10,000 looks up is fine. I replaced your following code to this,
let
Source = (#"IP Address" as text) => let
Source = Json.Document(Web.Contents("https://ipstack.com/json/" & #"IP Address")),
#"Converted to Table" = Record.ToTable(Source),
#"Transposed Table" = Table.Transpose(#"Converted to Table"),
#"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table")
in
#"Promoted Headers"
in
SourceReplacing the source name to new web address. I am getting this error,
DataSource.Error: Web.Contents failed to get contents from 'https://ipstack.com/json/203.56.182.115' (404): Not Found
Details:
DataSourceKind=Web
DataSourcePath=https://ipstack.com/json/203.56.182.115
Url=https://ipstack.com/json/203.56.182.115Can you please point me out what I am missing?
I also tried another site, https://www.ipinfodb.com/api Following your post and replaced the M query as follows,
let
Source = (#"IP Address" as text) => let
Source = Json.Document(Web.Contents("http://api.ipinfodb.com/v3/ip-city/?key=<APIkey>" & #"IP Address")),
#"Converted to Table" = Record.ToTable(Source),
#"Transposed Table" = Table.Transpose(#"Converted to Table"),
#"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table")
in
#"Promoted Headers"
in
SourceAnd getting this error,
An error occurred in the ‘fn_GetIPAddressDetails’ query. DataFormat.Error: We found extra characters at the end of JSON input.
Details:
Value=
Position=0I badly need this to work 😞 Please help
Thanks,
indhu
@GilbertQ did that and in that M code replaced <API> with the actual API key. Got the following error,
An error occurred in the ‘fn_GetIPAddressDetails’ query. DataFormat.Error: We found extra characters at the end of JSON input.
Details:
Value=
Position=0
Worked. Thanks a lot 😄
Back again, Gilbert! So we opted to continue with the IP stack API. I seeimingly still cannot get the function work once I click close & apply. The code definitely works as it loads up the table I want once I have invoked the custom function. The issue I keep coming up against is a web access issue after. I am using the http version of the website not the https. Is there a way of running the function so I can avoid this?
This is my code below.
= (#"IpAddress" as text) => let
Source = Json.Document(Web.Contents("http://api.ipstack.com/"&#"IpAddress"&"?access_key=MYAPIKEY"& "&security=1")),
#"Converted to Table" = Record.ToTable(Source),
#"Transposed Table" = Table.Transpose(#"Converted to Table"),
#"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table")
in
#"Promoted Headers"
Thanks,
S
How would I go about doing that? I'm only provided with two options. The website or the website + the IP address without the access key to follow.
= Table.AddColumn(#”Changed Type”, “fn_GetIPAddressDetails”, each Function.InvokeAfter(()=>fn_GetIPAddressDetails([IpAddress]), #duration(0,0,0,#”Interval (Secs)”)))
So i paste in the above code as your step says over the Invoked function column. But I get the error "Invalid Literal"
Hi there,
If you can change the double quotes to be ", as due to the copy and paste they are the italic double quotes
= Table.AddColumn(#"Changed Type1", "ParkRun", each Function.InvokeAfter(()=>fx_ParkRunData([Run]), #duration(0,0,0,#"Refresh Interval")))
Hey @GilbertQ, No worries I got it working. Takes a pretty long time but thats expected I have 4.3k Ip Addresses. Not sure if my issue is with the API service or not now because there is a limit. But I will come up with an issue that says "access to the resource is forbidden" with the url of the website "http://api.ipstack.com/[IpAddress]". This is the same issue I faced previously when using the API and seems the InvokeAfter.Function won't do the job....
Any other ideas?
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 39 | |
| 38 | |
| 38 | |
| 28 | |
| 27 |
| User | Count |
|---|---|
| 124 | |
| 88 | |
| 73 | |
| 66 | |
| 65 |