Forum Discussion

Foxxon28's avatar
Foxxon28
Helper I
1 year ago
Solved

Map visual Filtering - Tooltip

Dear reader,   For a specific business request I need to dynamically filter data clusters within a Power BI Map visual. My data setup is as follows:   Building_ID Fire_Hazard_Building_ID Lo...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi Foxxon28 ,

    If you want to follow your current requirement:

    As per your example I would expect the Count amount for Building ID = 3 to be 3. There are 3 buildings that have Fire_Hazard_Building_Id =3.
    
    Building_ID = 2 should return 0, as there are no Fire_Hazard_Building_ID's with value 2, therefore there is no risk. 

    You can change the DAX into this:

    BuildingCount_2 = 
    VAR _ID = SELECTEDVALUE('Table'[Building_ID])
    VAR _Count = CALCULATE(
        COUNTROWS('Table'),
        ALL('Table'),
        'Table'[Fire_Hazard_Building_ID] = _ID
    )
    RETURN
    IF(
        _Count = BLANK(),
        0,
        _Count
    )


    And the output:


    Considering your needs:

    Though it does in fact need filtering based on the "distance_to_Hazard" column.

    I suggest you first use this DAX to create a calculated table:

    Slicer = VALUES('Table'[Distance_to_Hazard_meter])

    Use this table to create a slicer, and change the measure BuildingCount_2 into this:

    BuildingCount_2 = 
    VAR _ID = SELECTEDVALUE('Table'[Building_ID])
    VAR _Count = CALCULATE(
        COUNTROWS('Table'),
        ALL('Table'),
        'Table'[Fire_Hazard_Building_ID] = _ID && 'Table'[Distance_to_Hazard_meter] IN VALUES(Slicer[Distance_to_Hazard_meter])
    )
    RETURN
    IF(
        _Count = BLANK(),
        0,
        _Count
    )


    Final output:
    If I select distance_to_Hazard from 0 to 10:

    The count change from 3 to 2.


    But I'm a little surprised that your current demand does not seem to have the same meaning as your previous demand:

    If I were to hover over Building_ID = 4, it would give me a count of 3 (Building_ID = 4 has Fire_Hazard_ID = 5. There are 3 buildings with Fire_Hazard_Buildig_ID = 5)

    Didn't you want to find out how many different Building_IDs are associated with the Fire_Hazard_ID corresponding to the Building_ID you selected? Did I misunderstand or have your requirements changed?

    Best Regards,
    Dino Tao
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.