
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Addmonths function with a negative integer
Hi all,
I'm trying to change the start date of periods from 1st day of month to 26th day of previous month.
For example, For December 2016 Period, it should be between November 26, 2016 and December 25, 2017
When I'm trying to load below, qlikview does not subtract a month but adds it.
Date(AddMonths(MonthStart(FiscalDate+25),-1), 'YYYY-MM') as Period
Could you please help me to solve this?
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try this:
Table:
LOAD Date(AddMonths(FiscalDate, -1) + 25) as Date,
Date(FiscalDate, 'YYYY-MM') as Period;
LOAD Date(MakeDate(2015, 12, 31) + IterNo()) as FiscalDate
AutoGenerate 1
While IterNo() <= 366;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
May be this:
Date(AddMonths(MonthStart(FiscalDate),-1)+25, 'YYYY-MM') as Period

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Unfortunately, it did not work.


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
try
Date(MonthStart(FiscalDate,-1)+25,'YYYY-MM') as Period
If a post helps to resolve your issue, please accept it as a Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can you share few rows of data to show what you are looking to do? what was the issue when you used your own script? What was different when you used mine?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Check if field "FiscalDate" is in date format.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is result according to my script:
And here is according to yours:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It did not work.
It works this way: ,


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
what exactly do you want to show in period? you wanted to subtract a month , the expression is subtracting a month!!
If a post helps to resolve your issue, please accept it as a Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try this:
Table:
LOAD Date(AddMonths(FiscalDate, -1) + 25) as Date,
Date(FiscalDate, 'YYYY-MM') as Period;
LOAD Date(MakeDate(2015, 12, 31) + IterNo()) as FiscalDate
AutoGenerate 1
While IterNo() <= 366;
