web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Populate Dropdown with...
Power Apps
Unanswered

Populate Dropdown with all years between two different year

(0) ShareShare
ReportReport
Posted on by 33

Hi,

 

I'm still a beginner with power apps, I want to populate a dropdown with a set of years and i'm looking for the function or way that allows me to do it.

 

Categories:
I have the same question (0)
  • mdevaney Profile Picture
    29,989 Moderator on at

    @ybelkouchi07 

    You can manually define the years by putting this code in the Items property of the dropdown

     

    [2017,2018,2019,2020,2021,2022]

     

     

    Another approach to make sure the years are always current is this

     

    [
     Year(Today())-2,
     Year(Today())-1,
     Year(Today()),
     Year(Today())+1,
     Year(Today())+2,
    ]

     

     

    But to populate the dropdown with all years between two given years is a bit trickier.  You will have to give the full details of how the app works for me to tell you if it is even possible.

     

    IMPORTANT: make sure you are using a Dropdown and not a ComboBox control.

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • ybelkouchi07 Profile Picture
    33 on at

    thank you for your answer, what if I wanted to insert 100 years, it's a dropdown who'll allow the user to choose a year.

  • mdevaney Profile Picture
    29,989 Moderator on at
    @ybelkouchi07
    What range of years do you want to populate the dropdown with?
  • ybelkouchi07 Profile Picture
    33 on at

    like from 1990 to 2040

  • Sank Profile Picture
    9 on at

    @ybelkouchi07 

     

    Save all years in a Data source, e.g. excel or share point list.

    Connect to data source from powerapps 

    Set items property of drop down to ‘Data source’.YearColumn


    Sank

  • mdevaney Profile Picture
    29,989 Moderator on at

    @ybelkouchi07 

    Put this code in the Items property of your dropdown.

    [1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035,2036,2037,2038,2039,2040]

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • ybelkouchi07 Profile Picture
    33 on at
    @Sank I want to avoid inserting my values manually
  • ybelkouchi07 Profile Picture
    33 on at

    @mdevaney 

    I had this in mind but is there any way to avoid doing that ?

  • Verified answer
    mdevaney Profile Picture
    29,989 Moderator on at

    @ybelkouchi07 

    No there is not.  This is because PowerApps does not have the equivalent of the FOR loop in other programming languages

     

    I suggest you store this code somewhere on your PC and delete the years you don't require.

    [1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035,2036,2037,2038,2039,2040,2041,2042,2043,2044,2045,2046,2047,2048,2049,2050,2051,2052,2053,2054,2055,2056,2057,2058,2059,2060,2061,2062,2063,2064,2065,2066,2067,2068,2069,2070,2071,2072,2073,2074,2075,2076,2077,2078,2079,2080,2081,2082,2083,2084,2085,2086,2087,2088,2089,2090,2091,2092,2093,2094,2095,2096,2097,2098,2099]
    

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • Community Power Platform Member Profile Picture
    on at

    I know this might be a little late but there is a way to easily populate years in a dropdown between two different years. I assume that you want a reasonable range which would be maybe -120 from current year and have that span all the way to today's year. This is how I did it in my app:

     

    Sequence(121,Year(Today())-120)

     

    What this does is: Sequence asks my for HOW MANY NUMBERS do I want in a sequence and I can also specify where I want it to start. So in my case I want to have 121 numbers (which is the roughly the oldest living person alive) and then I want it to start from today's year minus 120. This gives me a dropdown that in the year 2021 starts on 1901 and goes to 2021. Next year it will change to 1902-2022. The advantage of this approach is that it is futureproof.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard