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 / 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
    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

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 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard