How to compare last years sales with a graph

Here is my problem.
I want to make a graph that shows two numbers.

  1. This years sales by date.
  2. Last years sales by date.

I have several conditions.
First, only able to use the native query in my case(no custom questions)
Second, I want to use the field filters at the date , so we can change the 1 and 2 to any kind of time.

But I can’t understand how to use to different date field filters and showing the numbers to the graph properly.
I will really help me out if you guys know how to solve this issue.
For example, if you have some type of similar graph could you send me an sql sample?
Thank you.

Hi @coro
You cannot use Field Filter for that (unless you have a lookup table for dates and pull out min/max).
Use simple Date filters.
Search the forum, there’s a lot of examples on how to compare periods.
Not sure why you only want to do it in SQL instead of using Metabase’s UI:

1 Like

Thank you.
The reason why I’m not using Metabase’s UI is because our database structure is totally outdated.
To get the sales data, we have to use sub querys, and OR statements.
I think that Metabase’s UI cannot afford these kinds of SQLs.

@coro I would recommend that you create database views - then you only have to convert your data once, and then you would be able to use the Metabase UI.
I used to work with several legacy databases, so I know all the hoops you have to jump through to get anything to work correctly.

1 Like

Never even thought about database views.
Maybe that will figure things out, Thank you.

I was wondering, whats the benefits of using Metabase’s UI compared with coding SQL?

@coro Other people will be able to create questions, and you’ll have drill-through and x-ray functionality.
That doesn’t mean that you can create every question in the UI - there are some cases, where SQL is still needed.

1 Like