Hi SME,
I just build a simple Iterative macro to count down the years based on two inputs - the year input and the stop year. For example, if I put in 2022 for the year input and 2019 for the stop year, I would expect to see the following output showing the list starting with 2022 counting down to 2019.
This is a skeleton of a very complicated workflow. I'm trying to get this to work so that I can build on it and incorporate it into a much bigger workflow. I couldn't get the attached macro to work. Could you please help me figure out why the result doesn't show a list of the years (only shown one year)?
Appreciate it.
Thanks,
kwl
Solved! Go to Solution.
Here is the macro with the excel file generation and the correction in the iteration for you to see as an example.
my version is 2022.1
GM @geraldo !
I couldn't get the macro to work. When I input 2022 for the Input Year and 2019 for the Stop Year, I should see a list of dataset showing 2022, 2021, 2020, and 2019 listed along with the iteration number in each row. I created a text input and put in a year and then connected the macro, but I only got the 2022 for the Year and 2021 for the Iteration output in one row. BTW, I did change the formula to show [Year] - [Engine.IterationNumber] because I need the counting to go backward.
Could you please advise what I might have missed? Also, I'm not seeing anything coming from the i icon message.
Thanks,
kwl
I didn't understand the input year rule in relation to the stop year.
see this version of the macro
Thank you @geraldo! The macro's working now. I want to add another piece to the macro and I'm struggling with it. Essentially, I want to add Month to the macro. If I input the Year as 2023, Month as 4 and Stop Year as 2018, then I want to all the years prior to 2023 would have 12 rows for 12 months added for each year until 2018. For 2023, it would only had 4 rows for the first 4 months. The final output should be 45 rows from 2022-2018 with 1-12 month attached to each year plus an additional 4 rows for the first 4 months in 2023.
I used the Append Fields tool in the macro - obviously, I'm missing something. Could you please help me with the macro?
Many thanks,
kwl
Follows the macro with the month control setting.
See if this is what you need
Thank you so much! I would never have thought of using the Generate Rows tool - never used it before. This is such a creative way of doing this without resorting to the Append Rows tool. Appreciate your help!