QGIS: is there a way to specify labels for only some countries? - qgis

In QGIS,I want to display only the names of counties which have data of more than 1 (the data range is 1-18), and not display all country names on a world map.
I'm on a Mac.
I don't think 'priority' will work on its own, and it might need a string?
In the attributes, I have a column with no. projects (so 1-18 for <15 countries), and wondered if this could be part of the string. Something like 'if more than 1, label with country name'.

Related

GeoCharts, how to only display the countries name and not the value?

Similar to this post about showing countries names: GeoCharts how to show country names instead of codes
But with the added caveat of excluding the numerical value that also displays. The issue is I just want certain countries to display depending on the value but the value in itself is a meaningless token.

How to filter one source by clicking and filtering a bar chart from another source in Tableau?

I used an Apriori algorithm to view the frequent relationships in the dataset and I want to do a dashboard to better visualize this data but I don't know how to do this filter.
This is the bar chart that I created to show the support (amount of times something happend) and the confidence (probability of B happening given A) of these associations:
Apriori Chart
Next to it on the dashboard, I'll have a table with the full dataset used in this Apriori analysis where I have more information such as ID, Income, Hours Worked, etc:
Table from different data source
How can I create this relationship? The two data sources don't have a column in common that I can use for that.
I would need some way to:
Split the values in the antecedents columns by comma and filter only those columns with value equal to 1 in the other dataset
**Dataset A**
'Age Range <=30, Joblevel 1, Maritalstatus Single'
->
'Age Range <=30'
'Joblevel 1'
'Maritalstatus Single'
**Dataset B**
'Age Range <=30' == 1
'Joblevel 1' == 1
'Maritalstatus Single' == 1
Clicking this would filter the table next to it
Is there any way I can do this in Tableau?
You can download the tbwx i used in this example here https://community.tableau.com/servlet/JiveServlet/download/1083124-384949/Apriori.twbx
Thanks in advance for the help!
I am not able to check your twbx on the machine I'm using but I think you should be able to do this. The fields in the 2 data sources need to match so manipulate the data sources the make this happen.
For data source 1 there's a function SPLIT which will mean you are able to split the comma separated string to 3 fields.
Putting those 3 fields to the Detail shelf of your bar chart (or even Rows and hiding the header) will mean you can use them in an action filter.
Your second data source is a cross tab - post pivot. You should be able to pivot this data source. Highlight the measures and pivot them. This will give you the field Pivot Field Names and Pivot Field Values.
You only want to keep those with a value of 1 so create a calculated field
[Lookup1]: IF [Pivot Field Values] = 1 THEN [Pivot Field Names] END
Duplicate this field twice so you have Lookup1, Lookup2 and Lookup 3.
Then you should be able to action filter the table.
In the action filter set it up so SplitField1 = Lookup1, SplitField2 = Lookup2, etc.
Fingers crossed this works, I haven't been able to test so I am pulling it out of my head.

Display Tableau label to show group breakdown

I grouped my countries as followed (I used create --> group):
Asia = HK, JP, SG & Other = all other countries
So I am working with the following dimensions:
"Region" is the group created above. "Country" is the list of countries (e.g. HK, JP, SG, VT, CA, US, etc). "Date" & "Quantity"
I displayed a line chart that show trend for these 2 groups, so basically, on the same graph, one line shows the trend for "Other" and the other shows the trend for "Asia". "Day" is on the column shelf and quantity is on the row shelf, and I put Region on the color shelf to obtain the 2 lines. I also bring "Country" on the Filter shelf since I want to be able to view individual countries.
In the labels, when "ALL" is selected for "Country", I am able to display "Other" and "Asia". What I want is the label to change to the actual country when I select an individual country. For instance, if I select HK, I will only see the HK line, which is fine, but the problem is that it is labelled as "Asia" instead of HK. How can I make this happen?
I tried to add "Country" to the Label mark, unfortunately, that breaks down the trend lines to show "Other" and then all the countries that fall under Asia. I really just want to have 2 lines (or just one it a single country from "Country" is selected).
I have been banging my head trying calculated fields and parameters and can't get this to work. Please help!
This may be a bit extreme, but I can't think of another way.
With your 'Region' group on color and label, Tableau has no way of knowing when it is appropriate to change label to 'Country.' A calculated field would be very difficult to create here.
What I would propose is two completely separate sheets that are switched upon a user's input. Here is some documentation on how to create a sheet selector.
The method would generally be to:
Create a string parameter. Inside the parameter creation window there is an option "Add from Field" which would allow you to import all of your "Country" names. You will need to add an "All" label on this screen as well.
Create two views. One which is the one you already have that will show "All" and have two lines. The other new sheet will be designed for only when a single selection from the parameter list is made. It will only show one line that is labeled with the parameter (Country) name. You can design it however you'd like since its a totally separate sheet.
Follow the instructions in the link given above. In the article, on the step labeled "Type the current view's name (like “Map”) in the text box, and click the Add Item button." you will want to type the parameter name "All" in your first sheet and then in the second sheet you will want to individually label each country. The parameter drop down will trigger one sheet or the other for display.
A major consideration here is how often any fields are added to [Country]. Keep in mind that the parameter list will not automatically be adjusted if the underlying data changes.
I hope this helps.

Tableau Hierarchy Filter for Scatterplot

I am very new to Tableau, and I am trying to create a Scatterplot which can be viewed at different levels within the Hierarchy on the same Dashboard. For example, suppose I have employee counts, company counts and population density and I have this information by city, and these cities are in certain states.
I would like to be able to view the ratio # Employees/# Companies along the x-axis, population density along the y-axis, and I would like the ability to have each city shown as a separate bubble, and be able to, say, filter on Maryland, and show only the cities within for Maryland. This is all very straightforward using two quickfilters.
I'd also like to be able to somehow allow the user to specify that they want to see the bubbles at the State level, and once they select that option, it no longer shows the bubbles by city, it has aggregated those bubbles and is showing them by State. How do I do this?
Thanks!
Well, that is very easy to do when you are editing the view (just drag the field to detail and use the collapse option), but not so easy to provide this option to users.
I can think of a little hack. Create a parameter named [Level]. Make it a list of values, like 'City' and 'State'.
Now create a calculated field [Level of detail]:
CASE [Level]
WHEN 'City' THEN [City]
WHEN 'State' THEN [State]
END
I'm assuming your city and state fields are named [City] and [State].
Now drag this [Level of detail] field to details, and let the user choose the parameter. When he chooses 'State', it should aggregate on State level. Same for City.
One approach is to create a hierarchy out of the City and State fields.
To do that, in the data pane on the left, drag the City field and drop on top of the State field. You should get prompted for a hierarchy name of your choice, and then see the two fields grouped together in the data pane underneath the hierarchy name. State should be above City, but if not, just drag into the right order.
Now drag state to the detail shelf and build your view. Note there is a + sign to the left of State on marks card. You can press the + to expand the hierarchy and drill down to the City level. Then you can hit - to roll back up.
Custom hierarchies work for all kinds of discrete dimensions, not just those with geospatial roles.

Working with a delimited list of items in a Tableau field

I am preparing a data visualization in Tableau.
I have some data that can be simplified like this:
Name, Score, Tag
Joe, 5, A;B
Phil, 7, D
Quinn, 9, A;C
Bill, 3, A;B;C
I would like to generate a word cloud on the Tag field that counts
occurances of each item A,B,C. So I need to generate this:
A,3
B,2
C,2
D,1
In other words, I need help working with a field that contains a list of delimited values.
In the example data ; is the delimiter, but it could be anything.
I would like the word cloud to update as the user
applies filters, e.g. dragging a slider to set score > 5.
So the tag count has to be done on the fly.
I'm pretty sure I'll need to use field calculations and table calculations..?
Possibly I'll need to have a separate table tracking the tags..?
I have no problem building the word cloud and other viz elements.
What I'm looking for help with is parsing the delimited list field and
calculating the tag counts.
I do have full control over the source data, so if there is an easier way to
do this by reorganizing the schema, I'd be glad to do that. I thought of breaking
the field up into spearate tag1, tag2, tagX fields and trying to count over the
separate fields... but not sure if this is any simpler.
Thanks for any tips.
Another (probably better in your case) approach is to reshape the data before feeding it to Tableau. Tableau works best with normalized data.
Preprocess it to look like:
Name, Score, Tag
Joe, 5, A
Joe, 5, B
Phil, 7, D
Quinn, 9, A
Quinn, 9, C
Bill, 3, A
Bill, 3, B
Bill, 3, C
At that point, the standard Tableau word cloud charts should work well, and it will scale easily as you add more tags and data.
Reshaping data to normalize it prior to analysis with Tableau is a pretty standard step. Sometimes you can do it automatically, say with custom SQL, but often you'll have to use some sort of script first. If your data comes from Excel, Tableau has a plug in that can help with reshaping data. Look for it on the Tableau knowledge base.
Here's an approach that would be tolerable if you had a fixed set of 3 or 4 tags. Since you have closer to 50K possible tags, it's not a feasible approach for your problem as is. But maybe it will give you an idea. Similar approaches can be used to solve different kinds of problems in Tableau, so its a useful trick to know.
For each tag, create a boolean calculated field that returns 1 if the current row contains that particular tag and null otherwise (or whatever the condition is you want to detail)
For example, define a calculated field called Tag_A defined as:
if contains(Tag, "A") then
1
end
Similar, define calculated fields Tag_B, Tag_C etc
So far it's easy.
Then you can use those fields in other calculations to count the number of records that contain tag A, filter to only those that contain A, use the calculated field on the condition tab when defining sets that are computed dynamically by a formula ... Of course, the low level calculated field function can be more complex, say checking for the presence of at least 2 fields out of a list for example.
If nothing else, this approach sometimes lets you break complex problems into bite sized pieces.
Unfortunately, hard coding calculated field names won't scale to 50K tags. For that, you probably want to reshape your data.