Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
arjendewolf
Contributor
Contributor

Counting dimension in expression

Hi all,

I am trying to find a way to show the number of customers that went up and down in turnover per country (or other dimension) vs same period last year. I have two charts, one for turnover per countries which went up and another one for countries which went down in turnover.

This is the expression I use for displaying the turnover for countries that have increased in turnover vs same period last year ([Netto vk] is the sales amount):

if(sum({$ <Year={$(=max(Year))}, mydate={"<=$(=max(mydate))"}>} [Netto vk]) > sum({$ <Year={$(=max(Year)-1)},mydate={"<=$(=num(setdateyear(max(mydate),max(Year)-1)))"}>} [Netto vk]),

sum({$ <Year={$(=max(Year))}, mydate={"<=$(=max(mydate))"}>} [Netto vk])

)

  

Instead of showing the turnover, I’d like to show the number of customers for that country that have increased and the number of customers that have decreased in turnover. Any thoughts on how I could solve this?

I have made a flag (cuscounter) to aggregate.

Many thanks for your help!

Arjen

4 Replies
Anil_Babu_Samineni

May be this?

Count(

if(sum({$ <Year={$(=max(Year))}, mydate={"<=$(=max(mydate))"}>} [Netto vk]) > sum({$ <Year={$(=max(Year)-1)},mydate={"<=$(=num(setdateyear(max(mydate),max(Year)-1)))"}>} [Netto vk]),

sum({$ <Year={$(=max(Year))}, mydate={"<=$(=max(mydate))"}>} [Netto vk])

), Customer)

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
sunny_talwar

Or this

If(Sum({$ <Year = {$(=max(Year))}, mydate = {"<=$(=max(mydate))"}>} [Netto vk]) > Sum({$ <Year={$(=max(Year)-1)}, mydate = {"<=$(=num(setdateyear(max(mydate),max(Year)-1)))"}>} [Netto vk]), Count(DISTINCT {$<Year={$(=max(Year))}, mydate={"<=$(=max(mydate))"}>} Customers))

arjendewolf
Contributor
Contributor
Author

Thank you for your help so far! Unfortunately, this does not work, since the counting of the customers per country only happens if they have increased in turnover. I think I will have to use the P in set analysis. So i tried the following, but i'm not able to get the syntax right.

This expression works: sum({$ <code={">1"}, cusno = p({<sales= {">0"}>} cusno)>} cuscounter)

But when I try to add 'sum' to the set analysis, the expressions fails:

sum({$ <code={">1"}, cusno = p({<sum(sales)= {">0"}>} cusno)>} cuscounter)

Any thoughts on this?

Thanks again!

sunny_talwar

May be this

Sum({$<code={">1"}, cusno = {"=Sum(sales) > 0"}>} cuscounter)