Search code examples
powerbipowerbi-custom-visuals

Displaying custom map in Power BI


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.

enter image description here

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.

enter image description here

Its settings are like this :

enter image description here

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


Solution

  • 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 :

    enter image description here

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

    enter image description here

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