在Power BI中显示自定义地图

huangapple go评论134阅读模式
英文:

Displaying custom map in Power BI

问题

我在Power BI中使用地图可视化工具,以显示按城市划分的员工数量,当我按国家筛选时,一切都运行得非常完美。

例如,当我选择国家伦敦时,我的地图完美地缩放到该国家,并显示我的度量的返回值,按州进行划分。

这是我的度量,用于计算每个工作地点的员工数量:

员工每个工作地点 =
    CALCULATE (
        DISTINCTCOUNT ( FACT_EMPLOYEE_ENTRANCE_EXIT[FK_EMPLOYEE] ),
        USERELATIONSHIP ( FACT_EMPLOYEE_ENTRANCE_EXIT[FK_EMPLOYEE], DIM_EMPLOYEE[ID_EMPLOYEE] ),
        USERELATIONSHIP ( FACT_EMPLOYEE_ENTRANCE_EXIT[FK_WORKPLACE_REGION], DIM_WORKPLACEREGION[REGION_ID] )
    )

现在,我实际上找到了另一个漂亮且有趣的可视化,使用了来自这个YouTube教程的自定义地图。

其设置如下:

我实际上下载了JSON文件,我注意到它只有国家的名称。在YouTube示例中,当它按大陆筛选时,它显示了一个度量的分布(人口比例),并且正常工作。但是对于我的情况,我将按国家筛选,并且我将看到所选国家的每个城市有多少员工。但是,当我进行筛选时,它什么都不显示。唯一显示的情况是当我选择“卢森堡”时,这是一个国家的名称,但也是一个州/城市的名称。

我甚至尝试在我的数据集中添加经度和纬度,并将它们设置为相应的类别。我还将国家和城市(我在两个单独的维度中都有)设置为相应的类别。

链接到.json文件:pastebin.com/wQTprvyX

英文:

I'm working with the map visual in Power BI to show the number of employees per city when I filter by country, everything works perfectly fine.
For instance, when I choose the country London, my map is perfectly zoomed at the country and displays the return value of my measure per state.

在Power BI中显示自定义地图

This is my measure to count the number of employees per workplace:

    Employees Per Workplace =
CALCULATE (
    DISTINCTCOUNT ( FACT_EMPLOYEE_ENTRANCE_EXIT[FK_EMPLOYEE] ),
    USERELATIONSHIP ( FACT_EMPLOYEE_ENTRANCE_EXIT[FK_EMPLOYEE], DIM_EMPLOYEE[ID_EMPLOYEE] ),
    USERELATIONSHIP ( FACT_EMPLOYEE_ENTRANCE_EXIT[FK_WORKPLACE_REGION], DIM_WORKPLACEREGION[REGION_ID] )
)

Now, I actually found another beautiful and interesting visual using the custom map from this Youtube tutorial.

在Power BI中显示自定义地图

Its settings are like this :

在Power BI中显示自定义地图

I actually downloaded the JSON file and I noticed that it only has the names of countries. In the youtube example, when it filters by continent, it shows the distribution of a measure (Percentage of the population) and works correctly. However for my case, I'll be filtering by country, and I'll be seeing for each city of the selected country how many employees I have. Except that when I filter, it's not showing anything. The only case that it shows is when I choose "Luxembourg" which is the name of a country but also the name of a state/city.

I even tried to add longitude and latitude in my dataset and set them to the respective categories. I also set the country and city (which I have in 2 separate dimensions) to the respective categories

Link to the .json file : pastebin.com/wQTprvyX

答案1

得分: 1

你的问题与你映射到可视化的列有关。
为什么它总是显示卢森堡?
因为在dim_countries和dim_workplaceregion中都有相同的属性NAME。
在你的情况下,你应该在可视化中使用dim_countries的NAME列,而不是dim_workplaceregion。在下面的情况下,我选择了切片器中的突尼斯:

在Power BI中显示自定义地图

你可以检查,对于该选择,它返回了预期的输出。

在Power BI中显示自定义地图

附注:为了遵循最佳实践,请尝试像我在截图中所做的那样将度量分开成度量表。

英文:

Your issue is related to the columns you are mapping to your visual.
Why it is showing always Luxembourg?
Because, in both dim_countries and dim_workplaceregion there is the same attribute NAME.
In your case you should use in your visual the NAME column from dim_countries and not dim_workplaceregion. In the following case, I selected Tunisia in the slicer :

在Power BI中显示自定义地图

You can check that for that selection, it is returning the expected output.

在Power BI中显示自定义地图

NB : Just to follow the best practices, try to separate measures in a table measures like I did in the screenshot.

huangapple
  • 本文由 发表于 2023年6月11日 21:00:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/76450582.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定