Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to use count distinct from one period to another?

Dear Qlik Sense experts,

I am new to Qlik and have been struggling to get this expression to work properly in a table.

Columns; Order Year, Unique Items (Count(Distinct Item_Number)) and Unique Items from Year to Year

The column creating difficulties is the Unique Items from Year to Year and the expression I have been trying is in the line with;

  • COUNT({$<Item_Number = {"Before(Item_Number)"}>} Distinct Item_Number)

However, it returns "0" per year

Any ideas?

13 Replies
Not applicable
Author

Hi Kush,

Thank you for getting back again, it still return empty year column and 0 Unique Items Year to Year.

reddy-s
Master II
Master II

Do you need the unique count of items which do not exist in the previous years?

Not applicable
Author

Hi again, no, I need the unique count of what does exist in year in question AND did exist in the previous year (singular). I.e. distinct items that exist in both year and year -1

reddy-s
Master II
Master II

Hi Lasse,

If I understood your issue correctly, you need the distinct count of common items in this year and the previous year.

If so try this expression:

Expecting that you having a master calendar:create flags for this year and previous years using the inYear() function.

Once done: use this expression

count( {<items = P({1<[last year flag]={1}>} items)>}>} distinct items)

This will give you only the distinct count of common items bought in both the years

Thanks,

Sangram.