Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Mini_Elaine
Contributor III
Contributor III

100% stacked bar chart by year and month with various dates

Hi All,

I have the following data. I would like to plot 100% stacked bar chart based on the earliest sale date with whether the product has been sold within a month or not. As you can see, the product can be sold in multiple times in various dates. I would like only to use the earliest first sale date to plot bar chart. How could I get a 100% stacked bar chart by earliest sale date of its year and month?

Product typeFirst_sale_timefirst_sale_withinmonthon_shelf_datefirst_sale_date
Product60651Within a month01/04/202502/04/2025
Product606524Within a month01/04/202525/04/2025
Product6065  01/04/2025 
Product606693More than a month18/12/202421/03/2025
Product6066  18/12/2024 
Product607049More than a month09/12/202427/01/2025
Product6070  09/12/2024 
Product607256More than a month05/02/202502/04/2025
Product6072  05/02/2025 
Product6073    
Product607482More than a month10/10/202431/12/2024
Product6074  10/10/2024 
Product6075  29/05/2025 
Product6079  15/01/2025 
Product6080  17/06/2025 
Product6082  30/12/2024 
Product6084167More than a month02/04/202516/09/2025
Product6084  02/04/2025 
Product60853Within a month26/11/202429/11/2024
Product608611Within a month22/11/202403/12/2024
Product6086  22/11/2024 
Product608723Within a month29/10/202421/11/2024
Product6087  29/10/2024 
Product608826Within a month20/12/202415/01/2025
Product6088  20/12/2024 
Product6089  13/05/2025 
Product609127Within a month06/12/202402/01/2025
Product609161More than a month06/12/202405/02/2025
Product6091  06/12/2024 
Product60926Within a month14/02/202520/02/2025
Product6092  14/02/2025 
Product60930Within a month12/01/202512/01/2025
Product6093  12/01/2025 
Product60941Within a month12/02/202513/02/2025
Product6094  12/02/2025 
Product609591More than a month18/03/202517/06/2025
Product6095  18/03/2025 
Product6096    
Product609737More than a month14/01/202520/02/2025
Product60985Within a month05/06/202510/06/2025
Product6098  05/06/2025 
Product6099  13/08/2025 
Product6100  08/04/2025 
Product6101    
Product610226Within a month19/03/202514/04/2025
Product610329Within a month05/02/202506/03/2025
Product6103  05/02/2025 
Product6105    
Product6106111More than a month09/05/202528/08/2025
Product6106  09/05/2025 
Product61077Within a month03/03/202510/03/2025
Product6107  03/03/2025 
Product6108153More than a month10/07/202510/12/2025
Product6108  10/07/2025 
Product6109  19/12/2025 
Product61110Within a month27/03/202527/03/2025
Product6111  27/03/2025 
Product611218Within a month24/01/202511/02/2025
Product611319Within a month17/07/202505/08/2025
Product611562More than a month06/02/202509/04/2025
Product6115  06/02/2025 
Product6116  14/04/2025 
Product611899More than a month10/02/202520/05/2025
Product6118  10/02/2025 
Product6119  17/02/2025 
Product612015Within a month28/01/202512/02/2025
Product612051More than a month28/01/202520/03/2025

 

The 100% stacked bar chart I would like to show as below:

Mini_Elaine_0-1768992359557.png

How can I draw X axis with the earliest first sale for each product. Apparently X axis is the dimension. I couldnt put Min([first_sale_date.autoCalendar.YearMonth]) as X axis. 

 

Many thanks

Labels (4)
1 Solution

Accepted Solutions
Daniel_Castella
Support
Support

Hi @Mini_Elaine 

 

I'm not sure if I'm fully understanding your request. For example, for Product6091 you have two first dates in two different months and you want to always use the first of this two dates, right?

 

I used the following code in the backend:

Data:
LOAD Distinct
"Product type",
(Month(Min(first_sale_date)) &'-'& Year(Min(first_sale_date))) as first_sale_date
FROM [lib://DataFiles/Product Sales.xlsx]
(ooxml, embedded labels, table is Sheet1)
WHERE len(first_sale_date)>0
GROUP BY "Product type";

RIGHT JOIN(Data)
LOAD
"Product type",
First_sale_time,
first_sale_withinmonth,
on_shelf_date
FROM [lib://DataFiles/Product Sales.xlsx]
(ooxml, embedded labels, table is Sheet1)
WHERE len(first_sale_date)>0
;

 

First I take the minimum date for each product and I later join it to the main data. In this way, for this product I obtain the stacked data with the X axis as the minimum date.

Daniel_Castella_0-1768995036759.png

 

Let me know if it works for you. If not, could you, please, clarify a little bit the request?

 

Kind Regards

Daniel

View solution in original post

2 Replies
Daniel_Castella
Support
Support

Hi @Mini_Elaine 

 

I'm not sure if I'm fully understanding your request. For example, for Product6091 you have two first dates in two different months and you want to always use the first of this two dates, right?

 

I used the following code in the backend:

Data:
LOAD Distinct
"Product type",
(Month(Min(first_sale_date)) &'-'& Year(Min(first_sale_date))) as first_sale_date
FROM [lib://DataFiles/Product Sales.xlsx]
(ooxml, embedded labels, table is Sheet1)
WHERE len(first_sale_date)>0
GROUP BY "Product type";

RIGHT JOIN(Data)
LOAD
"Product type",
First_sale_time,
first_sale_withinmonth,
on_shelf_date
FROM [lib://DataFiles/Product Sales.xlsx]
(ooxml, embedded labels, table is Sheet1)
WHERE len(first_sale_date)>0
;

 

First I take the minimum date for each product and I later join it to the main data. In this way, for this product I obtain the stacked data with the X axis as the minimum date.

Daniel_Castella_0-1768995036759.png

 

Let me know if it works for you. If not, could you, please, clarify a little bit the request?

 

Kind Regards

Daniel

Mini_Elaine
Contributor III
Contributor III
Author

Dear Daniel,

That is perfect! Thank you!

I didn't realise I could work out the earliest date in data first rather than dimension from the dashboard. This works perfectly now.