<p dir="auto">Duplicate of <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="253540098" data-permission-text="Title is private" data-url="https://github.com/apache/superset/issues/3384" data-hovercard-type="issue" data-hovercard-url="/apache/superset/issues/3384/hovercard" href="https://github.com/apache/superset/issues/3384">#3384</a> <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="325527969" data-permission-text="Title is private" data-url="https://github.com/apache/superset/issues/5059" data-hovercard-type="issue" data-hovercard-url="/apache/superset/issues/5059/hovercard" href="https://github.com/apache/superset/issues/5059">#5059</a> - refer to these for existing discussion that was closed, while users were still asking for the feature.</p>
<p dir="auto">Didn't want this to get overlooked since there is currently no <strong>open</strong> issue for this.</p>
<p dir="auto">This issue serves as an open thread on this discussion.</p>
<p dir="auto">When you create a time series viz with a groupby and contribution <code class="notranslate">Total</code>, if at least one of the categories is missing a value for the date, no data points for that date are shown.</p>
<p dir="auto">This is sort of reasonable - technically, the data could be missing for the missing category, so it is not clear how to calculate contribution. However, in most cases, the missing data point corresponds to the value 0, and removing all the other data points is very confusing. In older charts (ex. line chart), contribution assumes 0 if data is missing, so we should provide some way to "fill" 0 for feature parity.</p>
<p dir="auto">I think there are two ways</p>
<ul dir="auto">
<li>Assume 0 whenever data is missing (similar to legacy line chart)</li>
<li>Have users use <code class="notranslate">resample</code> to fill missing values with 0. This is not possible yet because resample doesn't work if there's a group by - the error message is: <code class="notranslate">cannot reindex from a duplicate axis</code> and occurs <a href="https://github.com/apache/superset/blob/fd8461406d62e818c4bc88075ac25ddf44ba9caf/superset/utils/pandas_postprocessing.py#L981">here</a></li>
</ul>
<h4 dir="auto">How to reproduce the bug</h4>
<ol dir="auto">
<li>Go to SQL Lab</li>
<li>Run query:</li>
</ol>
<div class="highlight highlight-source-sql notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="SELECT DATE('2021-09-01') AS ds, 'hi' AS x
UNION ALL SELECT DATE('2021-09-02') AS ds, 'hi' AS x
UNION ALL SELECT DATE('2021-09-01') AS ds, 'whoa' AS x"><pre class="notranslate"><span class="pl-k">SELECT</span> <span class="pl-k">DATE</span>(<span class="pl-s"><span class="pl-pds">'</span>2021-09-01<span class="pl-pds">'</span></span>) <span class="pl-k">AS</span> ds, <span class="pl-s"><span class="pl-pds">'</span>hi<span class="pl-pds">'</span></span> <span class="pl-k">AS</span> x
<span class="pl-k">UNION ALL</span> <span class="pl-k">SELECT</span> <span class="pl-k">DATE</span>(<span class="pl-s"><span class="pl-pds">'</span>2021-09-02<span class="pl-pds">'</span></span>) <span class="pl-k">AS</span> ds, <span class="pl-s"><span class="pl-pds">'</span>hi<span class="pl-pds">'</span></span> <span class="pl-k">AS</span> x
<span class="pl-k">UNION ALL</span> <span class="pl-k">SELECT</span> <span class="pl-k">DATE</span>(<span class="pl-s"><span class="pl-pds">'</span>2021-09-01<span class="pl-pds">'</span></span>) <span class="pl-k">AS</span> ds, <span class="pl-s"><span class="pl-pds">'</span>whoa<span class="pl-pds">'</span></span> <span class="pl-k">AS</span> x</pre></div>
<ol start="3" dir="auto">
<li>-&gt; explore chart</li>
<li>Use time series bar chart v2 viz</li>
<li>Group by <code class="notranslate">x</code>, metric <code class="notranslate">count</code>, contribution <code class="notranslate">total</code></li>
<li>Note the missing data point for (<code class="notranslate">2021-09-02</code>, <code class="notranslate">hi</code>)</li>
</ol>
<h3 dir="auto">Expected results</h3>
<p dir="auto">Two bars should be shown for 09-01, one bar should be shown for 09-02</p>
<h3 dir="auto">Actual results</h3>
<p dir="auto">No bars are shown for 09-02, even though there is a data point</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/14146019/136434143-10bdd24f-82d7-405b-ae5c-25649928c7a0.png"><img src="https://user-images.githubusercontent.com/14146019/136434143-10bdd24f-82d7-405b-ae5c-25649928c7a0.png" alt="image" style="max-width: 100%;"></a></p>
<h3 dir="auto">Environment</h3>
<p dir="auto">(please complete the following information):</p>
<ul dir="auto">
<li>browser type and version: chrome</li>
<li>superset version: up to date with master as of 2021-10-01</li>
<li>python version: 3.8</li>
</ul>
<h3 dir="auto">Checklist</h3>
<p dir="auto">Make sure to follow these steps before submitting your issue - thank you!</p>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have checked the superset logs for python stacktraces and included it here as text if there are any.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have reproduced the issue with at least the latest released version of superset.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have checked the issue tracker for the same issue and I haven't found one similar.</li>
</ul>
<h3 dir="auto">Additional context</h3>
<p dir="auto">This is somewhat related to this issue: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="914747888" data-permission-text="Title is private" data-url="https://github.com/apache/superset/issues/15036" data-hovercard-type="issue" data-hovercard-url="/apache/superset/issues/15036/hovercard" href="https://github.com/apache/superset/issues/15036">#15036</a></p>