Forum Discussion
Shape Map color saturation not working
- 5 years ago
Hi Anonymous
I created some dummy data for other states then I created a column to store the color for the majority party and used that as color saturation
Majority Color = VAR _Dem = CALCULATE(COUNTROWS('Append1'), FILTER('Append1', 'Append1'[Party] = "Democrat" && 'Append1'[State Long] = EARLIER([State Long]) )) VAR _Rep = CALCULATE(COUNTROWS('Append1'), FILTER('Append1', 'Append1'[Party] = "Republican" && 'Append1'[State Long] = EARLIER([State Long]) )) VAR _Ind = CALCULATE(COUNTROWS('Append1'), FILTER('Append1', 'Append1'[Party] = "Independent" && 'Append1'[State Long] = EARLIER([State Long]) )) RETURN SWITCH( TRUE(), _Dem > _Rep && _Dem > _Ind, 0, _Rep > _Dem && _Rep > _Ind, 1, 2 )Because the Shape Map uses color shading, the different parties need discrete values to respresent them, each one can be assigned a specific color then.
You can also do this with a Filled Map where I worked out the majority party (similar code to above)
Majority Party = VAR _Dem = CALCULATE(COUNTROWS('Append1'), FILTER('Append1', 'Append1'[Party] = "Democrat" && 'Append1'[State Long] = EARLIER([State Long]) )) VAR _Rep = CALCULATE(COUNTROWS('Append1'), FILTER('Append1', 'Append1'[Party] = "Republican" && 'Append1'[State Long] = EARLIER([State Long]) )) VAR _Ind = CALCULATE(COUNTROWS('Append1'), FILTER('Append1', 'Append1'[Party] = "Independent" && 'Append1'[State Long] = EARLIER([State Long]) )) RETURN SWITCH( TRUE(), _Dem > _Rep && _Dem > _Ind, "Democrat", _Rep > _Dem && _Rep > _Ind, "Republican", "Independent" )Each party being assigned the relevant color.
The sample file above contains all this data and both maps.
Regards
Phil
Hi Anonymous
I created some dummy data for other states then I created a column to store the color for the majority party and used that as color saturation
Majority Color =
VAR _Dem = CALCULATE(COUNTROWS('Append1'), FILTER('Append1', 'Append1'[Party] = "Democrat" && 'Append1'[State Long] = EARLIER([State Long]) ))
VAR _Rep = CALCULATE(COUNTROWS('Append1'), FILTER('Append1', 'Append1'[Party] = "Republican" && 'Append1'[State Long] = EARLIER([State Long]) ))
VAR _Ind = CALCULATE(COUNTROWS('Append1'), FILTER('Append1', 'Append1'[Party] = "Independent" && 'Append1'[State Long] = EARLIER([State Long]) ))
RETURN
SWITCH(
TRUE(),
_Dem > _Rep && _Dem > _Ind, 0,
_Rep > _Dem && _Rep > _Ind, 1,
2
)
Because the Shape Map uses color shading, the different parties need discrete values to respresent them, each one can be assigned a specific color then.
You can also do this with a Filled Map where I worked out the majority party (similar code to above)
Majority Party =
VAR _Dem = CALCULATE(COUNTROWS('Append1'), FILTER('Append1', 'Append1'[Party] = "Democrat" && 'Append1'[State Long] = EARLIER([State Long]) ))
VAR _Rep = CALCULATE(COUNTROWS('Append1'), FILTER('Append1', 'Append1'[Party] = "Republican" && 'Append1'[State Long] = EARLIER([State Long]) ))
VAR _Ind = CALCULATE(COUNTROWS('Append1'), FILTER('Append1', 'Append1'[Party] = "Independent" && 'Append1'[State Long] = EARLIER([State Long]) ))
RETURN
SWITCH(
TRUE(),
_Dem > _Rep && _Dem > _Ind, "Democrat",
_Rep > _Dem && _Rep > _Ind, "Republican",
"Independent"
)
Each party being assigned the relevant color.
The sample file above contains all this data and both maps.
Regards
Phil
- Anonymous5 years agoNot applicable
PhilipTreacyThank you so much for this tremendous help! I have used your example and it worked with a tweak by adding the value 1 in Maximum field for the data color. I've tested it a few ways and it work exactly as I've been wanting it to. I'm still learning PowerBI and have to understand the backend functionality... Thank you, thank you for taking the time to help on this task!