Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

why is not ok for same expression.

the express is ok :

:   COUNT({<SHOPKEY= {"=(sum(SALES>0)"}  DISTINCT SHOPKEY)     is ok .

the same :

    COUNT({<SHOPKEY= {"=(sum(year={"$(=max(year)-1)"}SALES>0)"}  DISTINCT SHOPKEY)   isn't ok ,why ?

I want to get the number of shop which  have  sales in the the two year's same monthes .

example:

   sales     201401   201301      count(result)

shop1      234        230           1

shop2      0            230           0

shop3       344         0              0

how to write  it in table?

1 Solution

Accepted Solutions
jagan
Luminary Alumni
Luminary Alumni

Hi,

Try this

COUNT({<SHOPKEY= {'=(sum(year={"$(=max(year)-1)"}SALES>0)'}  DISTINCT SHOPKEY) 


OR


COUNT({<SHOPKEY= {'=(sum(year={$(=max(year)-1)}SALES>0)'}  DISTINCT SHOPKEY)  -- For Year(numeric) there is no need of Quotes.


Regards,

jagan.

View solution in original post

14 Replies
alexandros17
Partner - Champion III
Partner - Champion III

Because the second should be:

COUNT({<SHOPKEY= {"=(sum(year={"$(>=max(year)-1)"}SALES>0)"}  DISTINCT SHOPKEY)


that is >= last year

PrashantSangle

Hi,

You cannot use " inside "

Try to use '    ' for inner expression

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
senpradip007
Specialist III
Specialist III

try this:

COUNT({<SHOPKEY= {"=(sum({<year={"$(=max(year)-1)"}>}SALES>0)"}  DISTINCT SHOPKEY) 

Not applicable
Author

yes ,I can't use inside . but this I want two year's data the same time .

jagan
Luminary Alumni
Luminary Alumni

Hi,

Try this

COUNT({<SHOPKEY= {'=(sum(year={"$(=max(year)-1)"}SALES>0)'}  DISTINCT SHOPKEY) 


OR


COUNT({<SHOPKEY= {'=(sum(year={$(=max(year)-1)}SALES>0)'}  DISTINCT SHOPKEY)  -- For Year(numeric) there is no need of Quotes.


Regards,

jagan.

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

The above responses are all nearly there, this one fixes the bracket positions and closes the set expressions properly:

COUNT({<SHOPKEY= {"=sum({<year={'$(=max(year) - 1')}>} SALES) > 0"}>} DISTINCT SHOPKEY)

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

it is ok for  last year's 'sale. but I can't get result like my example :

one :

COUNT({<SHOPKEY= {"=sum({<YEAR={'$(=max(YEAR))'}>} SALES) > 0"}-{"=sum({<YEAR={'$(=max(YEAR)-1)'}>} SALES) <=0"}>} DISTINCT  SHOPKEY)

second

COUNT({<SHOPKEY= {"=sum({<YEAR={'$(=max(YEAR))'}>} SALES) > 0"},SHOPKEY={"=sum({<YEAR={'$(=max(YEAR)-1)'}>} SALES) <=0"}>} DISTINCT  SHOPKEY)

It seems  the same sales.

PrashantSangle

Hi,

Try this

1st expression:

=COUNT({<SHOPKEY= {"=sum({<YEAR={'$(=max(YEAR))'}>} SALES) > 0">}DISTINCT  SHOPKEY)

-COUNT({<SHOPKEY={"=sum({<YEAR={'$(=max(YEAR)-1)'}>} SALES) <=0"}>} DISTINCT  SHOPKEY)

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Not applicable
Author

but some shops is counted twice because both is zero.