
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How to display the sales of the last 10 days in a chart?
Hi all,
I have to display the sales of 10 last days so I will see in a column of a table ten rows and yesterday's sales at the top, the sales of 2 days ago below and so on. and in I have some fields to achieve that: sold_date which is the date where the ticket was sold, quantity is the number of tickets sold, so I would need sum(quantity).
I am currently trying to load specific data in the load editor from a table I already have, but I think it could be much easier to use an expression in a chart to achieve it.
This is the code I am using in the load editor that doesn´t work anyway ( sth relate to the where clause):
LOAD
DATE(sold_date) AS date,
SUM(quantity) AS total_sales;
[marts_event_ticketing]:
SELECT "sold_date",
"quantity"
FROM
"dbt_xavi_marts"."marts_event_ticketing"
WHERE
Date(sold_date) >= $(=Date_Add('$(=Today())', -10))
GROUP BY
DATE(sold_date);
Any clue? Many thanks!!
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is the 'sold_date' properly formatted and ensure it conforms with the format in the expression.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This expression will sum the quantities sold for the last 10 days based on the user's selection of dates.
Sum({<sold_date={">=$(=Date(Max(sold_date)-9, 'YYYY-MM-DD')) <=$(=Date(Max(sold_date), 'YYYY-MM-DD'))"}>} quantity)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Looked great but it didn´t work. I created a table and added a column with this expression and just a zero appears. I tried to add sold_date as a dimension and it was a null and a zero then.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I did this instead:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is the 'sold_date' properly formatted and ensure it conforms with the format in the expression.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It worked. I had another format when loading.
Thank you again BrunPierre!!
