Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
LINKEDIN LIVE: Democratizing data to enhance customer-centricity. JULY 29TH REGISTER TODAY
cancel
Showing results for 
Search instead for 
Did you mean: 
gab_cerelli
Contributor II
Contributor II

Count Distinct per years

Hi guys,

I've a sales database listed per date, location, season, ecc...

All I wanted is to do a count distinct that returns me only last year active stores, I tried with COUNT (DISTINCT ('STORES') with year as dimension but it doesnt' return me the correct values, how can I add more filters to this query? Maybe I've to introduce a new variable like Max_Year what do you think about it?

Thank you

Gabriele

Labels (3)
1 Solution

Accepted Solutions
MayilVahanan

Hi @gab_cerelli 

You can add more filter with comma separator like

Count({<Year={$(=Max(Year)-1)}, Country={'India', 'Singapore'}>}DISTINCT Store)

Thanks & Regards,
Mayil Vahanan R

View solution in original post

4 Replies
MayilVahanan

Hi @gab_cerelli 

Try like below

Count({<Year={$(=Max(Year)-1)}>}DISTINCT Store)

$(=Max(Year)-1) <-- it will give ur max year -1 values. 

for ex: Max year is 2021, it will give 2020 as result

Thanks & Regards,
Mayil Vahanan R
gab_cerelli
Contributor II
Contributor II
Author

Thanks so much for your answer Mayil, it seems working fine, what if I want to add more filters to this count?

MayilVahanan

Hi @gab_cerelli 

You can add more filter with comma separator like

Count({<Year={$(=Max(Year)-1)}, Country={'India', 'Singapore'}>}DISTINCT Store)

Thanks & Regards,
Mayil Vahanan R

View solution in original post

gab_cerelli
Contributor II
Contributor II
Author

Thanks my friend, you're the best!