Skip to main content
Announcements
Customer Spotlight: Discover what’s possible with embedded analytics Oct. 16 at 10:00 AM ET: REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Kris1
Contributor II
Contributor II

advanced scripting

Hi All,

Thanks for your help in advance. Please help how to write script for the following requirement.

Original Data
   
Programs Year
a 2021
ab 2021
abc 2022
abcd 2022
abcde 2023
abcdef 2024

 

Data format to be prepared Like this
     
Program Year New Year
a 2021 2021
ab 2021 2021
a 2021 2022
ab 2021 2022
abc 2022 2022
abcd 2022 2022
a 2021 2023
ab 2021 2023
abc 2022 2023
abcd 2022 2023
abcde 2023 2023
a 2021 2024
ab 2021 2024
abc 2022 2024
abcd 2022 2024
abcde 2023 2024
abcdef 2024 2024
Labels (2)
1 Solution

Accepted Solutions
MarcoWedel

 

Hi,

maybe one solution could be:

MarcoWedel_1-1638475927408.png

 

table1:
LOAD * INLINE [
    Programs, Year
    a, 2021
    ab, 2021
    abc, 2022
    abcd, 2022
    abcde, 2023
    abcdef, 2024
];

table2:
LOAD *, Year+IterNo()-1           as NewYear
While   Year+IterNo()-1<=MaxYear;
LOAD *, Alt(Peek(MaxYear),Year)   as MaxYear
Resident table1
Order By Year desc;

DROP Table table1;

 

 

hope this helps

Marco

View solution in original post

2 Replies
MarcoWedel

 

Hi,

maybe one solution could be:

MarcoWedel_1-1638475927408.png

 

table1:
LOAD * INLINE [
    Programs, Year
    a, 2021
    ab, 2021
    abc, 2022
    abcd, 2022
    abcde, 2023
    abcdef, 2024
];

table2:
LOAD *, Year+IterNo()-1           as NewYear
While   Year+IterNo()-1<=MaxYear;
LOAD *, Alt(Peek(MaxYear),Year)   as MaxYear
Resident table1
Order By Year desc;

DROP Table table1;

 

 

hope this helps

Marco

Kris1
Contributor II
Contributor II
Author

Hi MarcoWedel,

Thank you so much. Perfect solution .

once again Thank You so much.

Regards

Krish