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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Distinct list of month...
Power Apps
Answered

Distinct list of months and years

(0) ShareShare
ReportReport
Posted on by 187

Been racking my brains on this, but not come up with a solution yet.

 

I've got a collection of dates in a range and I'm trying to create a new collection from that, consisting of two columns - the distinct months and the years of those months.

 

e.g. my date range is from 2020-11-14 through to 2021-02-11 and I want the end result to be:

 

November2020
December2020
January2021
February2021

 

Getting the distinct months into a collection is easy enough, but it's adding the corresponding year that I'm stuck on. Any help would be appreciated.

Categories:
I have the same question (0)
  • Verified answer
    v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @JamesSnaps :

    I've made a test for your reference:

    1\I assume there is a collection named DateRange

    ClearCollect(
     DateRange,
     ForAll(
     Sequence(DateDiff(Date(2020,11,14),Date(2021,2,11),Days),0,1), 
     {TheDate:DateAdd(Date(2020,11,14),Value,Days)}
     )
    )

    1.JPG

    2\Add a date table control and set it's Items property to:

    ForAll(
     Distinct(
     ForAll(
     DateRange,
     {
     TheValue: Text(
     TheDate,
     "[$-en]mmmm"
     ) & ";;" & Year(TheDate)
     }
     ),
     TheValue
     ),
     {
     TheMonth: First(
     Split(
     Result,
     ";;"
     )
     ).Result,
     TheYear: Last(
     Split(
     Result,
     ";;"
     )
     ).Result
     }
    )

    2.JPG

    Best Regards,

    Bof

  • JamesSnaps Profile Picture
    187 on at

    This is really smart Bof, thanks for the assistance. I've learned some new tricks whilst looking through the solution too!

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 475

#2
WarrenBelz Profile Picture

WarrenBelz 387 Most Valuable Professional

#3
11manish Profile Picture

11manish 289

Last 30 days Overall leaderboard