繁体   English   中英

如何在 Power BI 中使用 IP 进行定位?

[英]How to use IP for location in Power BI?

当前正在尝试通过 IP 从 SQL-Server 数据源添加用户地图。 IP 要么映射到错误的位置,要么根本不使用 Power BI 的内置查找进行映射。

有没有办法通过 IP 列查询位置? 或者任何已知的 API 来为我做这件事?

试试这个: freegeoip.net

http://freegeoip.net/xml/8.8.8.8

它返回:

<Response>
<IP>8.8.8.8</IP>
<CountryCode>US</CountryCode>
<CountryName>United States</CountryName>
<RegionCode>CA</RegionCode>
<RegionName>California</RegionName>
<City>Mountain View</City>
<ZipCode>94035</ZipCode>
<TimeZone>America/Los_Angeles</TimeZone>
<Latitude>37.386</Latitude>
<Longitude>-122.0838</Longitude>
<MetroCode>807</MetroCode>
</Response>

或者使用 JSON:

http://freegeoip.net/json/8.8.8.8

{"ip":"8.8.8.8","country_code":"US","country_name":"United States","region_code":"CA","region_name":"California","city":"Mountain View","zip_code":"94035","time_zone":"America/Los_Angeles","latitude":37.386,"longitude":-122.0838,"metro_code":807}

我遇到了类似的问题,这就是我所做的。

  1. 我从源数据表中创建了一个具有不同 IP 地址表。
  2. 创建了一个自定义函数,用于查询 IP 地址并获取其详细信息(参见底部)。
  3. 单击功能区中的添加列,然后单击调用自定义函数
  4. 查询完成后,单击新列并通过单击右上角的图标展开表。

-- 对我有用的函数代码

= let
    Source = (#"IP Address" as text) => let
    Source = Json.Document(Web.Contents("http://freegeoip.net/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
    Source

来源

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM