Reputation: 4201
I have data about people in different months. For each person, there's a row per month, for whether they were:
# | person_id | month | drank_below_2_cups_of_water | had_headache | died |
# |-----------|------------|-----------------------------|--------------|-------|
# | 1 | 2024-02-01 | TRUE | TRUE | FALSE |
# | 1 | 2024-03-01 | TRUE | FALSE | TRUE |
# | 2 | 2024-02-01 | FALSE | TRUE | FALSE |
# | 2 | 2024-03-01 | TRUE | FALSE | FALSE |
# | 3 | 2024-02-01 | FALSE | FALSE | FALSE |
# | 3 | 2024-03-01 | TRUE | TRUE | TRUE |
# | 4 | 2024-02-01 | TRUE | FALSE | FALSE |
# | 4 | 2024-03-01 | FALSE | TRUE | TRUE |
# | 5 | 2024-02-01 | FALSE | FALSE | FALSE |
# | 5 | 2024-03-01 | TRUE | TRUE | FALSE |
# | 6 | 2024-02-01 | FALSE | FALSE | FALSE |
# | 6 | 2024-03-01 | TRUE | TRUE | TRUE |
Visualize a funnel analysis using a bar chart. Meaning:
drank_below_2_cups_of_water
(n = 7, see green cells) ;had_headache
(n = 4, see purple cells) ;died
(n = 2, see orange cells)Two separate bar plots that visualize the counts above, yet in a different way of calculating the proportions between bars.
1 – Relative to first bar
2 – Relative to previous bar
It's critical that in either plot, I want to label both counts and proportions on bars top.
I tried creating separate calculated fields.
// A
sum(if [Drank Below 2 Cups Of Water] then 1 else 0 end)
// B
sum(if [Had Headache] AND [Drank Below 2 Cups Of Water] then 1 else 0 end)
// C
sum(if [Died] and [Had Headache] and [Drank Below 2 Cups Of Water] then 1 else 0 end)
// A (rel to A)
[A] / [A]
// B (rel to A)
[B] / [A]
// C (rel to A)
[C] / [A]
Then, bringing them over to the canvas as separate fields we get almost what I need. I just want to know how to add the counts too, not just the proportions (see below in red – that's what I'm still missing).
Any idea how to achieve that? I'm open to any other suggestions, including structuring the data differently. I'm new to Tableau so looking for a best practice solution, as much as there is one.
Upvotes: 0
Views: 22
Reputation: 791
Create a calculated field and call it [People Count]
:
COUNT([Person Id]) //or COUNTD if you want distinct counts, although odd if someone dies twice...
Drag [People Count]
to the Label box in the Marks Pane
Format as needed.
Upvotes: 0