Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
tvbinoj
Contributor
Contributor

Variables in Count

Hi Team,
 
I am new to qlik sense..
 
I was trying to create a dashboard which will show the count of orders month-wise. 
I have added filters for month and year.
The requirement is when I select a month and year in the filters, let's say Aug 2023
 
1st KPI chart should show the number of orders for Aug 2023 ( which is the selected month)
2nd KPI chart should show the number of orders for Jul 2023 ( which is the previous month to selected month)
3rd KPI chart should show the number of orders for Aug 2022 ( which is the same month from last year)
 
I've created variables using getfieldselections option which will assign values to variables. Pls see below screenshot for value of variables after selecting Month as 8 and year as 2023.
 
The variable is showing the desired value (screenshot attached) but the count function with the variable (as below) is not giving the output (have used alternate state) as well. 
Count( {<[FILE CREATION YEAR & MONTH (NUM)]={"$(vPreviousYear)&'-'&$(vSameMonth)"}>} distinct [REFERENCE NUMBER])
 
Pls refer to attachment Screenshot 1
 
When I use the count function directly  (as below)  using '2022-8' the count is showing correctly. 
Count( {<[FILE CREATION YEAR & MONTH (NUM)]={'2022-8'}>} distinct [REFERENCE NUMBER])
 
Pls refer to attachment Screenshot 2
Looks like something is wrong with my variant or formula. 
 
Can you help me pls, I need this to be shown based on filter selection which means by variables.
 
Our requirement is, we should be able to choose any month and year in the filters for the first KPI and the other two KPIs should show the value accordingly.
 
For eg. 
 
if we choose July 2023 in the filters
1st KPI: Jul 2023, 2nd KPI: Jun 2023, 3rd KPI: Jul 2022
and 
if we choose Apr 2023 in the filters
1st KPI: Apr 2023, 2nd KPI: Mar 2023, 3rd KPI: Apr 2022
 
Please let me know if you need any additional info from my end.
Labels (3)
2 Replies
Vegar
MVP
MVP

There is a difference between using " " and ' ' in set modifier.

Using "2022-8" is the same as "2014", use single quotes instead so you get '2022-8'.

Try this:

Count( {<[FILE CREATION YEAR & MONTH (NUM)]={'$(vPreviousYear)-$(vSameMonth)'}>} distinct [REFERENCE NUMBER])

tvbinoj
Contributor
Contributor
Author

Thanks for your e-mail.

Issue resolved. There was a problem with my variables. I didn't use the '='
sign when I created those. Added the same and it is working now.

Thanks
Binoj.TV