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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
qlikconsultant
Creator III
Creator III

Transform from/to dates in a monthly table

Hi

i have the following table

Personalnumber Status from date to date

1, NEK, 01.12.2024, 28.02.2025

 

I have to transform in this format

Personalnumber Status Year Month

1, NEK, 2024, 12

1, NEK, 2025, 1

1, NEK, 2025, 2

 

Any suggestion what the best way is to transform this?

Labels (1)
1 Solution

Accepted Solutions
Dementor
Contributor II
Contributor II

Try while loop to create multiple items using conditions with IterNo()

Table:
LOAD
*
INLINE [
Personalnumber, Status, StartDate, EndDate
1, NEK, 01.12.2024, 28.02.2025
];


Table_v2:
load Personalnumber, Status,
Year(monthstart(date#(StartDate,'DD.MM.YYYY'),IterNo()-1)) as Year,
month(monthstart(date#(StartDate,'DD.MM.YYYY'),IterNo()-1)) as Month
Resident Table
while monthstart(date#(StartDate,'DD.MM.YYYY'),IterNo()-1) <=MonthStart(date#(EndDate,'DD.MM.YYYY'));

drop table Table;

Exit Script;

View solution in original post

3 Replies
Dementor
Contributor II
Contributor II

Try while loop to create multiple items using conditions with IterNo()

Table:
LOAD
*
INLINE [
Personalnumber, Status, StartDate, EndDate
1, NEK, 01.12.2024, 28.02.2025
];


Table_v2:
load Personalnumber, Status,
Year(monthstart(date#(StartDate,'DD.MM.YYYY'),IterNo()-1)) as Year,
month(monthstart(date#(StartDate,'DD.MM.YYYY'),IterNo()-1)) as Month
Resident Table
while monthstart(date#(StartDate,'DD.MM.YYYY'),IterNo()-1) <=MonthStart(date#(EndDate,'DD.MM.YYYY'));

drop table Table;

Exit Script;

Aditya_Chitale
Specialist
Specialist

Can you share sample data set and expected output ?

Regards,
Aditya

qlikconsultant
Creator III
Creator III
Author

It's in my post.