[Question] How to filter date data with bar chart.
Hello everybody, thank you for reading this.
To explain what I want to get, let's say there is table that has 3 columns: name, starting date, ending date. I want to show how many days are in between starting date to ending date with bar graph grouped by name so that X axis shows names and Y axis shows the number of days. For instance one row has name "A", starting date 2019-10-15, ending date 2019-10-30 so one bar will show name A has 15 days. This was easy when I do without time filter but problem I found is that when I want to show how many days are in certain time frame that user set. For instance, when user wants to see only for 2019-10-20 to 2019-12-01 from same data above, it should show only 10 instead of 15. I hope my question makes sense.
Does anybody have good idea how to solve this?
Issue-Label Bot is automatically applying the label #question to this issue, with a confidence of 0.84. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!
Links: app homepage, dashboard and code for this bot.
In custom sql on metrics field, you can use "<date column 1> - <date column 2>". This should help in your scenario.
@hemantaggarwal Thank you very much for your reply but I still couldn't get what I want. For instance I have "starting_date","ending_date" (not actually since it's in different language), I tried <ending_date>-<staring_date> and it gives "incorrect syntax" error. Could you give little more example?
@mingyumkim93 Your query syntax should be according the sql database you are using. For example I am using postgres as source in superset, so I have to use "ending_date" - "starting_date" in custom sql in metric field, also columns should be of date type. Below is one screenshot.

@hemantaggarwal Thank you very much, now I got it better hot it works. So it seems that I can't do what I want by setting time column and time range but maybe I have to do this in custom SQL somehow. Thank a lot for your help!
Yes, use custom sql to find difference between dates and if you also want dynamic time range then in time range filter choose either start_date or end_date as time column.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. For admin, please label this issue .pinned to prevent stale bot from closing the issue.