Trend issue when using Union

Hello,
I am currently trying to merge 2 tables and display the delta on one of the fields.
The requests look correct (Table shows only 2 values with 2 date), but I get "Nothing to compare for the previous ."

I tried 2 different requests:

  1. Reduce range on 1 table with "Where": https://prnt.sc/23ocjgj
  2. Reduce range on 1 table with "Order By DESC LIMIT 1" : https://prnt.sc/23ockk2

Funnily in the second request, if I order by ASC, the Trend display will work, but it is not the data I want to display ^^ (https://prnt.sc/23ock4t).

Do you have any idea how to solve this? Is this a bug? Or is there a workaround ?
Thank you for your help :wink:

I am using Metabase v0.41.2 with SQLite DB.

Hi @Neoraptor
First off, upgrade to latest release now: https://github.com/metabase/metabase/releases/latest
Second, you're not returning two dates. You're returning a date and a datetime/timestamp. I would guess that it has something to do with that.
SQLite is slightly different than other databases because of how it allows mixed data in the same column.

Hi @flamber and thanks for your answer :wink:
I'll update it right away.

The time format in both tables are Datetime : https://prnt.sc/23odanl
And I don't get why it works when sorted ASC but not DESC.
Is there a workaround to make it work?
It looks similar to this old issue > https://github.com/metabase/metabase/issues/11089

@Neoraptor Please post screenshots directly on the forum - you just paste and it will upload it.
The Trend visualization is a little complicated and needs some way of understanding the period, but you're giving it two arbitrary dates, which it probably doesn't understand.

I didn't see there was an auto uploader ! Sorry!
Here are my 3 attempts:

  • Filter with date:
    image

  • Limit results of first table (DESC) > Not working:
    image image

  • Limit results of first table (ASC) > Working:
    image

And here is the structure of the DB:
image

@Neoraptor When you're using SQL, then Metabase does not have an understanding on the granularity in the same way as when using GUI. This causes some problems.
Likely together with known issues like this:
https://github.com/metabase/metabase/issues/12388 - upvote by clicking :+1: on the first post

Is there anything else I can do to display the request I need?
It is still strange that for the same table displayed, once it works (when sorted ASC), once not (when sorted DESC).

@Neoraptor To get a Trend visualization? No, but outputting another visualization, or manually calculating the difference and showing that in a table column, could also be a workaround.

I am already using a simple value display, but wanted to have the nice Trend visualisation (with the daily increase
in % below the value).

@Neoraptor There's several issues open about Trends, so I would recommend that you go through those and upvote the issues you agree with:
https://github.com/metabase/metabase/issues?q=is%3Aopen+label%3AQuerying%2FX-rays+label%3AVisualization%2FScalars

Alright, I'll go upvote those :wink:
Thanks a lot for your support :slightly_smiling_face: