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

Announcements
Posting on Qlik Community is temporarily paused. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
aarnkalle
Contributor III
Contributor III

AddMonths to fetch current year data only

Hi

I am using below functions to fetch current year and current month less one month but I am getting data for all years.

Although month is as expected by me.

let vCurrentMonthYear  = '=year(addmonths(max(BillDate),1))';

let vPriorMonth  = '=month(addmonths(max(BillDate),-1))';

Please help.

Thanks and Regards,

Abhijit Arankalle.

5 Replies
nasirsaikh
Creator
Creator

Let vReportFromDate = YearStart(Date(BillDate));

Let vReportDate =  Date(AddMonths(Date(BillDate),-1))

then put on the load script..

Where BillDate>= '$(vReportFromDate)' and BillDate<= '$(vReportDate)'

OR

Where BillDate>= YearStart(Date(BillDate)) and BillDate<= Date(AddMonths(Date(BillDate),-1))

aarnkalle
Contributor III
Contributor III
Author

Hi Nasir

Thanks for your response but I am still not getting current year.

Regards,

Abhijit

nasirsaikh
Creator
Creator

check the date format it wil work or share the sample code

bwisealiahmad
Partner - Specialist
Partner - Specialist

Hi,

Are you trying to solve this in front end or load script?

If it is in front-end then share your current set analysis and someone will help write the expression. Nasir has already set you in the right direction.


Best,

Ali A

aarnkalle
Contributor III
Contributor III
Author

Hi

Thanks for your response. Actually, I am trying this in load script and I do not want user to update script every time to fetch current year and current month -1 data from SQL.

Thanks and Regards,

Abhijit Arankalle.