Specific grouping in Tableau (Heatmap) - tableau-api

I would like to join an Excel dataset which contain (but I don't know if its possible in here) :
The name of a course
The ID of a problem from this course (many pb per course)
The ID of a user that has submitted an answer for this problem from this course
the grade that the user has obtained at this pb from this course
What I try to achieve, it is a graph like those ! It's supposed to be call : Gradient-map, Colormap or Heat-map.
Axe x : Every problem for each course
Axe y : value of the grade (from 0 to 100)
Axe z : Number of user for each Note value
So, if for the pb A of the Course A, the dispersion is like this:
9 users have 100
21 users have 80
40 users have 60
5 users have 40
10 users have 20
15 users have 0
I would like to have every value displayed on a bar and each value would be displayed by a square. Each square having a different color regarding the value represented.
So, here, 60 would be darker than any other value (since the amount of people having this grade is the greatest) and 20 would be clearer than 0, 60, 80 & 100 but darker than 40
Then, just next to this bar, the same but for the pb B & C. Then, next to it, the pb A, B & C for the course B, etc

Move grade, name of a course, ID of a problem to Dimensions.
Put name of a course and ID of a problem on the columns.
Put grade on the rows.
Find a drop down list on the Marks tab and select Square.
Put COUNT(ID of a user) on the Color on the Marks tab

Related

Different filter to axis X and Y

Type Value Year
1 2 1907
2 3 1907
3 1 1907
4 5 1907
. . . .
1 24 2021
2 41 2021
3 10 2021
4 81 2021
I want to make a scatter plot and with dynamic filtering in a dashboard, choose which type to plot in. But the problem is when filtering I can only make that filter affects both X and Y axis. How to make a filter to X axis and other for Y axis?
One solution is to create two parameters to ask the user which types to use for the x and y axes, both of type whole number. Show both parameter controls (right click)
The purpose of the parameter is to ask the user a question and record the response. Each parameter can have exactly one value at a time, even though it can have a list or range of possible values.
Then create a boolean calculated field to determine whether a data record should be included, such as X type = X parameter and Y type = Y parameter (Its not clear from your problem description what those criteria really are)
Then put your calculated field on the filter shelf, and only include data records where the calc evaluates to True.
I'm new to Tableau but I have never seen a filter used on anything except selecting which rows to process.
You can accomplish what you describe by having one sheet per X-axis field you want, normal filtering on the rows ( Y-axis) , and a parameter on a dashboard to pick which sheet to display.
https://help.tableau.com/current/pro/desktop/en-us/dashboards_sheet_selector.htm

Tableau - Toggle between 2 measures by single select filter on one basic text grid

looking to have a basic text grid by month by product, and then have a single filter on only 2 of the measures. For example:
Measures Filter
------------------
[ ] Sales <-- only show this
[X] Quantity <-- and this as options
[ ] Interest (don't show in filter)
[ ] Fee ( don't show in filter)
JAN | FEB | MAR | APR | MAY | etc ...
products
ITEM1 x x x x x
ITEM2 x x x x x
ITEM3 x x x x x
So the user can basically toggle between Sales or Quantity, and whichever they click on will fill out the x by month.
I was able to get this to work for everything except only showing the 2 measures I want to filter for. It only shows all measures for me in the filter and I can't figure out how to hide them.
What I did was
Drag Date to columns
Drag Product and MeasureNames to Rows
Can someone please help me on getting this correct? Any help or guidance is appreciated!
This is not the correct use case of FILTERS. Filters are normally used to filter (read subset) the data (read rows). Say for example If your dataset has 1000 rows/records and you want some report/visual/aggregation on say 500 rows (based on some criteria of course) you have to filter the data. For selection of argument (user based) in some report/viz, etc. Parameters are used.
Your desired example output is also a perfect case of use of Parameters. You may proceed as follows-
Step-1 Create a parameter (say parameter 1) with values as SALES and QUANTITY.
Step-2 Create a calculated field (say CF1) with the following calculation
CASE [parameter 1]
WHEN 'SALES` THEN [sales]
WHEN 'Quantity' then [Quantity]
END
Note: It is assumed that your field/column names in dataset are sales and Quantity
Step-3 Build your view (Crosstab here) with
months on Columns shelf
products on rows shelf
CF1 on text in Marks card (alternatively just double click it)
Choose measure for aggregation of CF1 as desired (default will be sum)
Step-4 right click paramter 1 and click show parameter. (select desired measure for aggregation in crosstab)
VOILA your desired view is complete. Good luck.
There is another options to add to Anil's good suggestion. You can also use Measure Names as a filter. Hide all measures apart from those you want in the filter, then put Measure Names on the filter shelf.
However, this means you can't use the hidden measures from the data source elsewhere, which can be a deal breaker. Duplicating the data source is a way around that limitation.
But if you only want to show the 2 measures and are happy with single select, then choosing the measure by parameter is the better option, as Anil suggests.

How to insert a table into another table's entry in SQL

Let's suppose I have a table:
name amt
A 1
B 3
C 8
And I now want to insert that table into another table's entry. For the purpose of this example lets say we insert that table into entry X:
name table
Z
X A 1, B 3, C 8
Y
What query can I use to do this?
The values can be comma separated, in fact I am not too worried about the format, I just need that data in the entry.
Underlying problem (Why I want to do this):
Let's say I have a group of districts. Lets call them districts A, B, and C. Now I would like to know the number of red, blue, and green houses in district A. Simple, I just make a new table that would filter out districts B and C and then count the groups of houses. So, assuming I have 8 red houses, 12 blue houses, and 2 green houses, we get the resulting table:
# of houses color
12 blue
8 red
2 green
I now want to store this in our original table for future reference. So I make a new column, and add
District Group_Data
A 12 blue, 8 red, 2 green
B
C
Now in the future I may want to do the same for districts B and C, and the same process would follow.
Any other ways to solve this problem are welcome if simpler.

Tableau - Name Rank, by State / Year / Gender

I have a data set downloaded from the Social Security website. The data is in the form below, and contains the popularity (i.e., as defined by Count) of names, by gender, year and state:
State Gender Year Name Count First Letter
AK F 1910 Anna 10 A
AK F 1910 Annie 12 A
AK F 1911 Annie 6 A
AK F 1912 Alice 5 A
AK M 1912 Wilbur 7 W
AK M 1912 Thomas 7 T
Within Tableau, I'd like to Top X names by each of these categories (or all if not filters are applied). However, when I use a Top filter in a visualization, the underlying data produced by the filter is the form:
For example, I need the first ranked name, and be able to use filters to see how that changes by year, gender, and state. I'm thinking this might be accomplished by an LOD expression, but not sure where to start.
You can achieve this without needing a LOD calculation. Simply change your filters from standard blue dimension filters to be context filters. To do this simply right click on the filter when it is in the filter pane and click "Add to Context". The filter will be shown as grey. Now all ranks will be calculated after filters have been apllied
Why does this work? It is to do with the Order of Operations in Tableau. A calculation such as rank is a table calculation. As the name implies the calculation is processed on the entire data table before dimension filters are applied. However, when something is a context filter it creates temporary tables which are then used to calculate table cals.
Find out more here: https://www.google.com.au/search?q=order+of+operations+tableau&oq=order+of+operations+tableau&aqs=chrome..69i57j0j69i65j0j69i65j0.3475j0j7&sourceid=chrome&ie=UTF-8

Does Window_SUM really sort the data in Tableau?

Does WINDOW_SUM actually sort the data? what if my table looks like this
userid | price
1 | 5
2 | 6
3 | 7
1 | 10
and say I need the output like below (just one column)
total_price_by_user
15
6
7
clearly I need a sum distinct as a calculated field so I can do the below but I wonder if window_sum actually sorts the data or not and the userid should not be displayed in the output so it should exactly look like above?
WINDOW_SUM(IIF(ATTR([userid])==ZN(LOOKUP(ATTR([userid]), -1)), 0, [price]))
You are working too hard.
Just put make sure Userid is a discrete (blue) dimension and then place it on a shelf, such as the Rows shelf. Then make sure price is a continuous (green) measure and place it on a shelf, such se the Columns shelf. Tableau will aggregate the data and display the sum of all the price values for each user id.
To change a field from dimension to measure, simply drag it to the appropriate section in the data pane on the left (i.e. the pane showing all the field names)
If you want Tableau to sort your users by sum, click the sort button in the toolbar.
Save table calculations like Window_Sum() and lookup() for the occasional special cases that the simpler approaches don't cover.