If you are OK with three colors which are assigned to specific three countries, you can use three parameters.
However this option does not allow to set same color on multiple countries..
dynamic color map_+SM_10.0.twbx 63.0 KB
The goal is to be able to assign 1 of 3 colors to any country in the world
in arbitrary combination. Here I used just a handful of them as an example.
Also before a shape and single color is selected they should be grey.
My solution with exclusive filter is quite combersome. The whole process
one click on the map to select country
one click to choose the color
It may not be possible though.
This is completely different approach which I don't know satisfying your request or not.
Preparing small table to pick each country's color.
I needed add gray as one more color in the data, though..
User should pick the color setting with ctrl key.
dynamic color map_SM_10.0_v2.twbx 143.4 KB
I appreciate your help, Shin. I like your idea however with more marks or colors it will be quite difficult to handle
Let me share my new approach based on an exclusive filter again but this time I take advantage of the fact that we can determine which value was excluded.
So effectively it works as if it was multi value inclusive filter hence you do not need to exclude the colors you do not want but just the one you actually want. This time I used more countries and colors:
here is public version: Tableau Public
what do you think?
dynamic color map.twbx 156.3 KB
Simply WOW :-)
it's way too creative, even mind-bending to me.
it took time to understand how the "inverse" exclusion filter works.
great stuff with prime numbers & modulo & parameters.
frankly, i couldn't be even close to find the way on my own.
I think that's cool idea.
I appreciate your big effort to make this function work.
Thank you both for your kind words - Спасибо! It really makes feel good to
receive such positive feedback from you.
I'm going to be more active here soon, I promise:)
Completely different approach attached. I think this is a much simpler approach.
This was a super-fun exercise, but I didn't quite get it where I wanted it as there are a few things I don't like about it, and I'm out of time tonight:
Maybe someone can get the last of these drawbacks nailed down for me.
1) I have it down to a single country select>single color select, but after you select a color on filter, the filter re-populates all the countries, and I'm not sure why.
2) The Color Value Selected is an aggregate, and I couldn't figure out a way to formulaicly return the color name rather than the value. This means you have to code the color values as well as the color names and make sure they line up, or don't use the color legend at all, just rely on the text in the autofilter. The Color Value Selected values could be aliased, but that's not completely automatic, so I didn't want to do that.
I started from scratch, so I'll just list the basic steps here:
1) I pointed excel at the Wikipedia page for "list of Eurpean countries" and just imported it direct with PowerQuery, for speed and ease. Filtered out a few eastern countries by hand just for western Europe view
2) created a second table in Excel with list of colors I want, each with it's own numeric value. Shouldn't matter what the values are, as long as they are numeric and distinct.
3) cross joined countries to colors with join criteria 1=1
4) combined Color and Country, threw resultant field on filter as exclude values
5) Two LOD calculations added to context filter, one that sums up the color values for each country, the other counts how many values there are - both evaluated before filters
6) Color Value Selected first makes sure the count of color values in view is exactly 1 less than the total for the country, then takes the total color value in context filter, and subtracts the sum in view to get the difference, resulting in the value for the color that was filtered out. A value of zero can be interpreted as either more than one color selected, or no color selected, and assigned grey color.
7) Action on the dashboard filters the color sheet on country, and filter shows only related values.
Color Map.twbx 88.1 KB
I really like your simplified approach.
Well done Justin.
- the re-populated filter can be hidden behind a floating object so I would not worry about that
- I noticed that in the attached workbook the quick filter does not retain selection unless it is applied to 'all using this datasource'
- I was trying to implement a version with simple sum based on binary values which does not require any LoD or table calculations (for prime numbers product):
But as soon as I tried to drop [excluded value] onto color mark I got this:
This should allow for more combinations that the 'primes product' and its performance should be better - although tableau throws an exception...
Color Map Binary 10.0.twbx 47.2 KB
There seems to be a bug related to power operator ^ used in calculations as it works when hardcoded:
Why do I want binary numbers for color values rather than 1, 2, 3, ..? It is not used in this scenario but it will allow to uniqely determine any combination of excluded values and not just the first one meeting the criteria. That is why I used primary numbers too previously.
Color Map Binary 10.0.twbx 57.1 KB
I don't entirely follow the binary calculation, though it's easy to understand why it would perform better. Math is not in the forefront of my job, so I'm rusty on all things mathy. I'd love if you could point us toward a blog or article that overviews the concept behind your technique - or just spell it out if it's straight forward enough.
Only thing I don't like about it is that you have to hard code the list of values in a calculation. If you add a new color to the dataset, you have to alter the calculation to handle it, which I was very specifically trying to avoid.
Another thing that occurred to me last night (on my attempt) is that if Tableau had a hash or checksum function of some kind, you wouldn't even have to assign each color a value in your source data, you could just hash the color string itself, and the technique would work the same.
1 of 1 people found this helpful
6 colors can be encoded with bits, when all are included then it is 111111 which translates to 2^6-1=63. If you exclude one of them you may get 111101 which is 2^6-1 - 2^1.
Multiple exclusions can be determined, e.g. 110101 which is 2^6-1 - 2^3 - 2^1.
If Tableau allowed binary literals it would seem more natural.
If tableau allowed bitwise logical oprations (AND/&) I would not have to hardcode the total number of colors. But instead LoD or parameter can be used (if not that bug).