Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Counter Visualization: count rows never shows zero #4265

Closed
susodapop opened this issue Oct 18, 2019 · 6 comments · Fixed by #4385
Closed

Counter Visualization: count rows never shows zero #4265

susodapop opened this issue Oct 18, 2019 · 6 comments · Fixed by #4385

Comments

@susodapop
Copy link
Contributor

susodapop commented Oct 18, 2019

Issue Summary

If I toggle Count Rows and my query returns no results, the visualization disappears. It should show "0". It makes sense for the visualization to disappear if it points at a field and row index. But sometimes the number of rows is actually zero and this should be reflected by the counter.

Steps to Reproduce

  1. Write a query that returns a single row: SELECT 'foo', 'bar'
  2. Add a counter visualization and toggle Count Rows. The counter will show 1.
  3. Add a NULL WHERE clause to the query ... where 1 =2. The counter disappears.

Technical details:

  • Redash Version: 7, 8, 9alpha
  • Browser/OS: Firefox / Chrome / Safari
  • How did you install Redash: Saas / Docker
@susodapop
Copy link
Contributor Author

Identified on the forum here.

@kykrueger
Copy link
Contributor

I'm also experiencing the same issue. It gives the impression that a count on a dashboard has an error in the query when 0 rows returned should be a legitimate result.

@dmudro
Copy link
Contributor

dmudro commented Nov 21, 2019

I wrote a fix for this including bunch of unit tests for client/app/visualizations/counter/utils.js.
Am not able to push my branch and create the PR though, getting 403. Maybe @arikfr can advise?

@arikfr
Copy link
Member

arikfr commented Nov 22, 2019 via email

@dmudro dmudro mentioned this issue Nov 22, 2019
2 tasks
@dmudro
Copy link
Contributor

dmudro commented Nov 22, 2019

It makes sense for the visualisation to disappear if it points at a field and row index.

Ok that part stayed untouched but there is a tiny edge case that might be worth looking into:
image

The default dropdown item with non existent value could be seen as a small inconvenience from a UX perspective. I've seen a similar behaviour in other dropdowns throughout the app and the user typically cannot revert to the non-existent default value after interacting with the form control (which makes sense).

A suggestion to overcome this particular one would be to merge the Count Rows toggle and the Counter Value Column Name dropdown (the toggle at the bottom is a bit odd IMHO anyway):
image

@gabrieldutra
Copy link
Member

Hi @dmudro thanks for pointing that out, there is #4366 to allow more aggregate functions in the Counter visualization, so the "Count rows" will probably be merged into a "Counter Type" dropdown soon. Regarding the inconvenient non existent value, that seems a bug, I'll investigate further on that as it should either show a placeholder or select a valid column value by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants