Hi, I am trying to figure out what is the problem.
I am creating 2 SQL questions in Metabase from one view
You can clearly see that I am creating a variable filter on the field, and it doesn`t work properly, because dates from October are shown
but if I am replacing that variable filter with SQL code that does the same(copypasted from another question), it does work as expected: only September is shown
I tried to recreate it in other questions, but everything worked fine there.
Metabase vers: 0.44.4
OS: Debian
Browser: Chrome
So, I did some experiments and somehow found that:
I don`t have any ideas, how does it work
TonyC
January 26, 2023, 3:16pm
#2
Can you upgrade to 45? Because i think you are hitting this:
opened 10:38AM - 19 Sep 22 UTC
closed 09:38PM - 30 Sep 22 UTC
Type:Bug
.Correctness
Querying/Parameters & Variables
Querying/Native
.Backend
**Describe the bug**
When using Date Filters and setting up relative dates "sta… rting from" the range specified provides inconsistent results. There is inconsistency between the frontend and backend:
<img width="925" alt="image" src="https://user-images.githubusercontent.com/110378427/190998425-aa71aeb4-3f36-4a98-88d9-256483d5c7da.png">
**To Reproduce**
Steps to reproduce the behavior:
1. Go to New -> Sql Query -> Select Sample Database
2. Paste the following query:
```
Select MIN(CASE WHEN {{pre}} THEN CREATED_AT END) AS pre_min,
MAX(CASE WHEN {{pre}} THEN CREATED_AT END) AS pre_max
FROM orders
```
4. Set Variable Type Field Filter, Field to Map -> CreatedAt, Filter Widget Type -> Date Filter
5. Go to filter -> Relative Dates -> Choose Starting From -> Starting From 36 months and past 1 month ... Run query and notice inconsistency in the image above
**Expected behavior**
The result should filter for just 1 month. Since even the description is stating "Previous Month, Starting 36 months ago"
<img width="568" alt="image" src="https://user-images.githubusercontent.com/110378427/190999704-c97cf633-3a60-4b81-aaad-5bb75a2b1180.png">
Notice that setting the value to 0 gives correct result but inconsistent range:
<img width="617" alt="image" src="https://user-images.githubusercontent.com/110378427/190999904-e2be9ceb-bc4c-44f5-a543-429c54a0f0f2.png">
"
**Information about your Metabase Installation:**
- Metabase version: Tested on both 1.43.0 and 1.44.3 ... Seems to be a bug introduced with the new date filter widget
**Additional Context**
This behaviour doesn't happen if you create a Question. The only issue I think might be good to consider/fix is that it allows you to input 0 and even though nothing is outputted the preview shows a range which makes sense from a logic perspective but not a user perspective, it can be removed altogether to not allow the input of 0 but this is trivial and just adding here as additional context
<img width="1226" alt="image" src="https://user-images.githubusercontent.com/110378427/191017615-2bf70334-1c83-4ec2-8164-d0f5a02fb3a0.png">
Shame on me, that I overlooked it. Thank you, update fixed my problem
1 Like