Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
BARC’s The BI Survey 19 makes it official. BI users love Qlik. GET REPORT
aarnkalle
New 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
Contributor

Re: AddMonths to fetch current year data only

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
New Contributor III

Re: AddMonths to fetch current year data only

Hi Nasir

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

Regards,

Abhijit

nasirsaikh
Contributor

Re: AddMonths to fetch current year data only

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

Partner
Partner

Re: AddMonths to fetch current year data only

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
New Contributor III

Re: AddMonths to fetch current year data only

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.