I have a Looker table with number of negatives and positives per month. I need my visualization to show only the positive rate (either as a percentage or proportion of total positives and negatives).
Looker can easily plot the percentages of both negatives and positives on the same graph, but if I "hide" negatives, the positive percentage balloons to 100%. Thats not right. I want to plot the actual positive percentage out of total.
Is there a visualization option or table calculation I could use to achieve this?
Here's what my data currently looks like:
Status (pivoted) | Negatives | Positives |
Month | Count Distinct Cases | Count Distinct Cases |
month_1 | 3 | 7 |
month_2 | 4 | 2 |
month_3 | 1 | 5 |
month_4 | 5 | 5 |
Ideally my data would like this and I could plot the Positive Rate (as proportion or percentage):
Status (pivoted) | Negatives | Positives | |
Month | Count Distinct Cases | Count Distinct Cases | Positive Rate |
month_1 | 3 | 7 | 0.7 |
month_2 | 4 | 2 | 0.33 |
month_3 | 1 | 5 | 0.83 |
month_4 | 5 | 5 | 0.5 |
Solved! Go to Solution.
Maybe the pivot is giving trouble.
Try creating a filtered measure on the count distinct cases directly. Pass filter condition to identify positive cases from them. Then create another % measure from this new field (the option would be % of column). This will create a field to calc % of positive cases.
Now hide the previous measure column so that only month and exact % fields can be used to show in the Viz.
Maybe the pivot is giving trouble.
Try creating a filtered measure on the count distinct cases directly. Pass filter condition to identify positive cases from them. Then create another % measure from this new field (the option would be % of column). This will create a field to calc % of positive cases.
Now hide the previous measure column so that only month and exact % fields can be used to show in the Viz.
So this worked ! (with a minor modification to the final step). In the final step I want percentage of row, not column. You need a table calculation to do that.
Here's the raw data:
Month | Count Total Cases |
month_1 | 10 |
month_2 | 6 |
month_3 | 6 |
month_4 | 10 |
Then create filtered measure on Count Total Cases where I grab the positive cases. So the data then looks like this:
Month | Count Total Cases | Positive Cases |
month_1 | 10 | 7 |
month_2 | 6 | 2 |
month_3 | 6 | 5 |
month_4 | 10 | 5 |
Then create a new table calculation where I calculate the proportion of Positive Cases out of Total Cases: ${positive_cases} / ${count_total_cases}}
That gives you this final format, where you can plot Positive Yield:
Month | Count Total Cases | Positive Cases | Positive Yield |
month_1 | 10 | 7 | 0.70 |
month_2 | 6 | 2 | 0.33 |
month_3 | 6 | 5 | 0.83 |
month_4 | 10 | 5 | 0.5 |