Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I'd need to create a bar chart with:
- year quarter on X axis (ex. Q1 2026)
- number of new customers on Y axis (as customers who bought in actual period and didn't in previous)
example:
for Q1 2026 the value of Y axis should be calculated as number of customers who bought in Q1 2026 and didn't in Q4 2025 and so on...
The end user should be able to filter by product/product category and any other filters in the UI.
Then it can't be pre calculated in the script.
Could you help me to find the best way to achieve it?
Many thanks in advance for your time.
Best Regards
I guess an Aggr() function is needed...nested aggregation not allowed.
Yes, an aggr() will be needed to aggregate the results of the more granular conditions. Depending on the data-set it might not be necessary to sum the sales else just checking if any sales exists. It may look like:
sum(aggr(
-(count({< YQI = {$(=max(QYI)), $(=max(YQI)-1)}>} distinct YQI)=1),
CustomerID))
sum(aggr(
-(count({< YQI = {$(=max(QYI)-1), $(=max(YQI)-2)}>} distinct YQI)=1),
CustomerID))
... and so on - maybe 8 expressions to reflect the trend of two years - and the expression-labels are: max(QYI), max(QYI)-1 ....
ps. YQI = year(Date) * 4 + quarter(Date)
if i well understood the bar chart will have 8 expressions to cover 2 years, one for each quarter ?
what about chart dimension?
Each bar covers a quarter therefore no year-quarter or other period-information are needed respectively mustn't be applied.
I was trying to go through Quarter as a chart dimension and using Aggr() e Above() functions in the expression but with no success.
I do think the only way to achieve it is using one expression for each time period with no time dimensions.
Can you try this:
Count(
Aggr(
IF(
Count(Expression1) + Sum({1} 0) > 0
AND
RangeSum(Above(Count(Expression1)), 0) = 0,
1
),
MonthYear, Dim1
)
)You can change Dim1 to Customer, MonthYear to Quarter and Expression1 to Sales.
hi
this post may help
The solution could be :
Prepare Quarter Start Date and lets name it :- vquarterstart in Charts variable:-
then in set expression use the measure:-
Count({<Date={">=$(=vquarterstart)"},CustomerName = e({<Date={"<$(=vquarterstart)"}>})>}CustomerName)
In the variable You can use:-
vquarterstart = addmonths(yearstart(max(Date)),3*(floor((num(month(Max(Date)))-1)/3)))
Or If you have have new version of qlik
you can use
vquarterstart = quarterstart(max(Date))