Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
sersal10
Creator
Creator

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!!

Labels (3)
1 Solution

Accepted Solutions
BrunPierre
Partner - Master
Partner - Master

Is the 'sold_date' properly formatted and ensure it conforms with the format in the expression.

View solution in original post

5 Replies
BrunPierre
Partner - Master
Partner - Master

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)

sersal10
Creator
Creator
Author

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.

Captura de pantalla 2024-04-29 a las 13.20.41.png

sersal10
Creator
Creator
Author

I did this instead:

Captura de pantalla 2024-04-29 a las 13.22.07.png

BrunPierre
Partner - Master
Partner - Master

Is the 'sold_date' properly formatted and ensure it conforms with the format in the expression.

sersal10
Creator
Creator
Author

It worked. I had another format when loading.

Thank you again BrunPierre!!