"current month" not working for one SQL question

I am just getting started with Metabase, so this is probably my problem, but help would be appreciated.

I have written a set of SQL queries to pull data on a set of KPIs, and all of them are working good except for one.

In order to group them by month, I am taking their creation date and doing this:

STR_TO_DATE(CONCAT(YEAR(gift_date),’-’,MONTH(creation_date),’-’,‘01’), “%Y-%m-%d”)

I am using that in the SELECT output as well as in the GROUP BY clause.

I am also using a date filter in the were clause, just an:
[[ AND {{ creation_date }} ]]

Now, if I do a range like “Past 6 days - Including today”, I get results in February. If I do a range of “Past 6 months - Including this month”, I don’t get any February results.

This is strange becuase the other SQL queries I have built seem to work fine with the “Including this month” flag.

Any ideas where I should look?

[[UPDATE]]
Even if I take the grouping out entirely and just do “creation_date”, and get the raw detail, it misses the current month/day/etc.

Hi, based on the fact that you use “include today” I guess you use v0.28? As I still haven´t updated yet I can´t reproduce your query.
But one thing you could do to check is rather than grouping it by month, group it by day and see if the filter “last 6 days - including today” include todays values?

You would find out that if “include today/this month” works at all.
Let me know the results :slight_smile:
Eva

The “include current month” is working with the other queries, which is why this puzzled me. :slight_smile: I just tried creating a new question and it is doing the same thing when I use “Previous x months including this month”, but “previous x days including today” works.

…and I just tried Previous 1 Year (including this year)" and it does not pull from this year, so something is perhaps broken.

Hm … weird. As I said I sadly have to go blind here as I can´t try it myself.
Just checked and it seems this is already an issue filed on github:


If you can add any details to this issue please do as then metabase might have more chance to fix it :slight_smile:
Sorry that you found a bug so quickly!
Eva

Thanks, I just assume it is my mistake first, so started here. :slight_smile:
I’ll watch it over there.

As a workaround, I made my SQL a question to pull the newly created records. I thne built another question that used my SQL question as the data source, and by using the filtering there, grouping by creation_date:Month and using the sum of created records, I got the results I needed.

1 Like

thanks for sharing - a great workaround!