Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I have this load script for one of my app in Qliksense.
Table1:
Load
First_Name,
Last_Name,
Salary,
Fiscal_Year
SQL Select
FirstName as First_Name,
LastName as Last_Name,
Salary,
FY as Fiscal_Year
From XYZ_Table
In the sheet, I have this simple table with Fiscal_Year column that shows all the data for all the years.
User requested to filter the data to only shows the current year and two previous years. I have adjusted my code to this:
Table1:
Load
First_Name,
Last_Name,
Salary,
Fiscal_Year
SQL Select
FirstName as First_Name,
LasrName as Last_Name,
Salary,
FY as Fiscal_Year
From XYZ_Table
WHERE Fiscal_Year >= (YEAR(GETDATE())-2); //to get only year 2024 and 2023,2022//
It loaded successfully and I got no errors, but when I go to my table in the sheet, I still see years from 2016-2021
I am not sure what I am missing. Could someone please help me with this?
thank you!
As mentioned earlier and as evident from the snippet, 'FY' is a varchar type, and 'YEAR(GETDATE()-2' will be an integer, so the comparison might not be precise.
Try
Where Cast(FY as int) >= YEAR(GETDATE()-2;