Skip to main content
Solved

generate numbers between two values

  • July 24, 2024
  • 3 replies
  • 120 views

zizou84
Contributor
Forum|alt.badge.img+1

Hello,

I need to generate data by year (whereas I only have periods)

To do this, I'll need to generate numbers between two values (typically years) to make a join with my existing data.

I thought of using counter but I need input data, I just want to generate all the numbers between two values (for ex 1791 to 2024)

thanks in advance for your help

 

Best answer by nielsgerrits

I think you want a feature for each year between 1791 and 2024? One way to do this is:

  • Expected input is one feature with attributes FromYear = 1791 and ToYear = 2024.
  • Calculate the difference between the 2 years.
    • AttributeCreator
      • AttributeName: Years
      • AttributeValue: @Evaluate(@Value(ToYear)-@Value(FromYear))
  • Create a feature for each year.
    • Cloner
      • Number of Copies: Years
      • Copy Number: Year Number
  • Create a Year attribute for each feature
    • AttributeCreator
      • AttributeName: Year
      • AttributeValue: @Evaluate(@Value(FromYear)+@Value(YearNumber))
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

3 replies

nielsgerrits
VIP
Forum|alt.badge.img+62
  • Best Answer
  • July 24, 2024

I think you want a feature for each year between 1791 and 2024? One way to do this is:

  • Expected input is one feature with attributes FromYear = 1791 and ToYear = 2024.
  • Calculate the difference between the 2 years.
    • AttributeCreator
      • AttributeName: Years
      • AttributeValue: @Evaluate(@Value(ToYear)-@Value(FromYear))
  • Create a feature for each year.
    • Cloner
      • Number of Copies: Years
      • Copy Number: Year Number
  • Create a Year attribute for each feature
    • AttributeCreator
      • AttributeName: Year
      • AttributeValue: @Evaluate(@Value(FromYear)+@Value(YearNumber))

zizou84
Contributor
Forum|alt.badge.img+1
  • Author
  • Contributor
  • July 24, 2024

Thank you very much, I will try your solution !


zizou84
Contributor
Forum|alt.badge.img+1
  • Author
  • Contributor
  • July 24, 2024

Works perfectly !

 

Thanks a lot for the help!