Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
RimDataAnalyst
Contributor III
Contributor III

Generate date between date start and date end

Hello ,
I have income that I want to spread over the duration of a contract I have the start date and the end date of the contract and I want to generate the different months between the two dates
for example the strat date = 06/21/2022 and the End date: 03/12/2025:
the dates generated will be: 06/21/2022, 07/21/2022,
so on until 03/10/2025, 03/11/2025 and 03/12/2025
and the income will be distributed in a linear fashion over the different dates
here is the script I developed for that but it generates a syntax error can you help me :

fact_rewards_tmp3:

Load Distinct
[Product - Name], ICAO, [AC Type],Conf,MSN,[Customer profile], Partner ,Contract_Start_Date_real,Contract_End_Date,Value_by_partner,[Value Generation (k$/Tail/Yr)], [Platform Fee],
[End Date], [Start Date] ,[Campaign Status],pricing ,dal_revenus,air_revenus1 ,ge_revenus
,Date(addmonths([Start Date], 1)) as ReferenceDate
Resident fact_rewards_tmp2

While (addmonths([Start Date], 1)) <= date(max([End Date]));

Labels (4)
4 Replies
Or
MVP
MVP

Nothing in your code seems to actually be considering the iteration number... perhaps something along the lines of:

addmonths([Start Date], IterNo()-1)

?

RimDataAnalyst
Contributor III
Contributor III
Author

i added iterNO to the script but this error appears :

The following error occurred:
Aggregation functions not allowed here.
Or
MVP
MVP

That seems correct - you can't use Max() in the While statement, I suppose. You should grab the max value into a variable and then use that instead.

RimDataAnalyst
Contributor III
Contributor III
Author

t creates the different dates but it doesn't match well with the end date and start dates and diffèrent income :

RimDataAnalyst_0-1669818895982.png