Forum Discussion
Map visual Filtering - Tooltip
- Anonymous1 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.
Create a Measure:
BuildingCount =
CALCULATE (
COUNTROWS ( 'YourTable' ),
ALLEXCEPT ( 'YourTable', 'YourTable'[Fire_Hazard_Building_ID] )
)
Use the BuildingCount measure as the size of the bubbles on the map.
Add slicers for relevant fields (e.g., Distance_to_Hazard_meter).
💌 If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn
Thanks for the swift reply!
However this doesn't work when I don't have anything pre-filtered. If no filters are applied it seems to count all the Fire_hazard_id rows. Only for when I pre-filter a specific Fire_Hazard_Building_ID, it correctly counts the cluster. Whereas I want to calculate it beforehand.
- Kedar_Pande1 year ago
Super User
What is expected when no filters are applied?
- Foxxon281 year ago
Helper I
When no filters are applied I would expect it to count the Building_Id's for it's MIN Fire_Hazard_Building_ID.
For example as per my previous sample data:
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)
- Anonymous1 year agoNot applicable
Hi Foxxon28 ,
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)It looks like you are setting the Building_ID field as a slicer or filter? Then you can try the following DAX:
Measure = IF( ISFILTERED('Table'[Building_ID]), CALCULATE ( DISTINCTCOUNT ( 'Table'[Building_ID] ), ALLEXCEPT ( 'Table', 'Table'[Fire_Hazard_Building_ID] ) ), CALCULATE( DISTINCTCOUNT ( 'Table'[Building_ID] ), 'Table'[Fire_Hazard_Building_ID] = MINX(ALL('Table'), 'Table'[Fire_Hazard_Building_ID]) ) )
I don't know how you created your map visual object, so I can only provide you with DAX but cannot help you test it. If the result is incorrect or you have more than one filter, please describe your visual object creation process and all the filter fields used in detail, thank you!
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.