Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Ayden
Contributor III
Contributor III

filter data current year

hello fellow Qlik developers, please i have few questions.

1. how do i write an expression that would filter my Data table with information for current year. I have a field with dates which I converted to year like so YEAR(Field).

2.  I want to create Two variables that i can use with the variable input chart at the front end 

( questions how do i create those variables at the script level that shows sum(Qty) and the other is the multiplication of fields Unit*Qty. want to be able to use the variable input to toggle my application.

 

Thanks in Advance 

 

5 Replies
AshutoshBhumkar
Partner - Specialist
Partner - Specialist

Hello,

1. You can write the expression like Sum({<Year = {"$(=Max(Year))"}>}) to get sales for Current/Max Year.

2. To create variables in Script and store Qty value and Unit*Qty, you need to make calculations in the table and use Peek function to get and store that specific value in the variable.

 

Thanks,

Ashutosh

Ayden
Contributor III
Contributor III
Author

thanks for your response, how can i use peek to achieve this. could you please show me an example.

 

 thanks 

AshutoshBhumkar
Partner - Specialist
Partner - Specialist

Check this example.

 

Table:
load * inline [
Date, Week, ID, Sales
9/1/2021, 1, A, 10
9/1/2021, 1, B, 20
9/7/2021, 2, A, 32
9/7/2021, 2, C, 31
9/14/2021, 3, A, 20
9/15/2021, 3, B, 25
9/16/2021, 3, D, 20
9/20/2021, 4, A, 20
9/20/2021, 4, D, 25
9/21/2021, 4, B, 10
9/27/2021, 5, A, 20
9/27/2021, 5, F, 25
9/28/2021, 5, D, 20
10/4/2021, 6, A, 25
10/5/2021, 6, B, 11
10/6/2021, 6, C, 12
10/11/2021, 7, A, 10
10/11/2021, 7, C, 25
];


SalesTable:
Load Sum(Sales) as TotalSales
Resident Table;

Let vSalesVariable = Peek('TotalSales',0,'SalesTable');


Exit Script;

 

Thanks,

Ashutosh

Ayden
Contributor III
Contributor III
Author

thanks it work now i get this below any idea how to fix it. 

3FB553CF-4B85-42D7-B3B4-0E408ED4E020.jpeg

AshutoshBhumkar
Partner - Specialist
Partner - Specialist

Hello,

Variables created in script and frontend will hold only one value.

You can writes simple Sum(Sales) in the variables.

What exactly is the requirement ?