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 / Combining 2 Collection...
Power Apps
Answered

Combining 2 Collections that will be used for Column Charts

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I have this formula;

 

ClearCollect(
   CombinedCollection,
   AddColumns(
      Sort(
         GroupBy(
            AddColumns(
               Filter(
                  RMT_Roster,
                  DateValue('Roll in Date') >= DateValue("9/1/" & Text(Year(Today()) - If(Month(Today()) < 9, 1, 0), "[$-en-US]0000")) &&
                  DateValue('Roll in Date') <= DateAdd(DateValue("9/1/" & Text(Year(Today()) - If(Month(Today()) < 9, 1, 0), "[$-en-US]0000")), 1, TimeUnit.Years) - 1
               ),
               "MonthYear",
               Text(Month(DateValue('Roll in Date')), "[$-en-US]00") & "/" & Text(Year(DateValue('Roll in Date')), "[$-en-US]0000"),
               "Type",
               "Roll in"
            ),
            "MonthYear",
            "Group"
         ),
         "MonthYear",
         SortOrder.Ascending
      ),
      "Roll in Count",
      CountRows(Group)
   ),
   AddColumns(
      Sort(
         GroupBy(
            AddColumns(
               Filter(
                  RMT_Roster,
                  DateValue('Roll off Date') >= DateValue("9/1/" & Text(Year(Today()) - If(Month(Today()) < 9, 1, 0), "[$-en-US]0000")) &&
                  DateValue('Roll off Date') <= DateAdd(DateValue("9/1/" & Text(Year(Today()) - If(Month(Today()) < 9, 1, 0), "[$-en-US]0000")), 1, TimeUnit.Years) - 1
               ),
               "MonthYear",
               Text(Month(DateValue('Roll off Date')), "[$-en-US]00") & "/" & Text(Year(DateValue('Roll off Date')), "[$-en-US]0000"),
               "Type",
               "Roll off"
            ),
            "MonthYear",
            "Group"
         ),
         "MonthYear",
         SortOrder.Ascending
      ),
      "Roll off Count",
      CountRows(Group)
   )
)
 
However with produces 2 rows of data. just like in the attached photo. how can i combine this into single row only? Combined Collection.png
Categories:
I have the same question (0)
  • Verified answer
    v-yueyun-msft Profile Picture
    Microsoft Employee on at

    Hi , @Anonymous 

    This is my test data:

    vyueyunmsft_0-1709803932057.png

    ClearCollect(test2, ForAll( testdata.'Roll off Date',{MonthYear: Text(Month(DateValue('Roll off Date')), "[$-en-US]00") & "/" & Text(Year(DateValue('Roll off Date')), "[$-en-US]0000")})
    ,ForAll( testdata.'Roll in Date',{MonthYear: Text(Month(DateValue('Roll in Date')), "[$-en-US]00") & "/" & Text(Year(DateValue('Roll in Date')), "[$-en-US]0000")})
     );
    Set(ResultTest ,AddColumns( Distinct(test2,MonthYear) As months , "Roll in Count" , CountRows( Filter(testdata, Text(Month(DateValue('Roll in Date')), "[$-en-US]00") & "/" & Text(Year(DateValue('Roll in Date')), "[$-en-US]0000")=months.Value ) ) ,"Roll off Count", CountRows( Filter(testdata, Text(Month(DateValue('Roll off Date')), "[$-en-US]00") & "/" & Text(Year(DateValue('Roll off Date')), "[$-en-US]0000")=months.Value ) ) ));

    The result is as follows:

    vyueyunmsft_1-1709803971573.png

     

    In your side, you can try to use this code:

    ClearCollect(test2, ForAll( Filter(
     RMT_Roster,
     DateValue('Roll in Date') >= DateValue("9/1/" & Text(Year(Today()) - If(Month(Today()) < 9, 1, 0), "[$-en-US]0000")) &&
     DateValue('Roll in Date') <= DateAdd(DateValue("9/1/" & Text(Year(Today()) - If(Month(Today()) < 9, 1, 0), "[$-en-US]0000")), 1, TimeUnit.Years) - 1
     ).'Roll off Date',{MonthYear: Text(Month(DateValue('Roll off Date')), "[$-en-US]00") & "/" & Text(Year(DateValue('Roll off Date')), "[$-en-US]0000")})
    ,ForAll( Filter(
     RMT_Roster,
     DateValue('Roll in Date') >= DateValue("9/1/" & Text(Year(Today()) - If(Month(Today()) < 9, 1, 0), "[$-en-US]0000")) &&
     DateValue('Roll in Date') <= DateAdd(DateValue("9/1/" & Text(Year(Today()) - If(Month(Today()) < 9, 1, 0), "[$-en-US]0000")), 1, TimeUnit.Years) - 1
     ).'Roll in Date',{MonthYear: Text(Month(DateValue('Roll in Date')), "[$-en-US]00") & "/" & Text(Year(DateValue('Roll in Date')), "[$-en-US]0000")})
     );
    
    Set(ResultTest ,AddColumns( Distinct(test2,MonthYear) As months , "Roll in Count" , CountRows( Filter(Filter(
     RMT_Roster,
     DateValue('Roll in Date') >= DateValue("9/1/" & Text(Year(Today()) - If(Month(Today()) < 9, 1, 0), "[$-en-US]0000")) &&
     DateValue('Roll in Date') <= DateAdd(DateValue("9/1/" & Text(Year(Today()) - If(Month(Today()) < 9, 1, 0), "[$-en-US]0000")), 1, TimeUnit.Years) - 1
     ), Text(Month(DateValue('Roll in Date')), "[$-en-US]00") & "/" & Text(Year(DateValue('Roll in Date')), "[$-en-US]0000")=months.Value ) ) ,"Roll off Count", CountRows( Filter(Filter(
     RMT_Roster,
     DateValue('Roll in Date') >= DateValue("9/1/" & Text(Year(Today()) - If(Month(Today()) < 9, 1, 0), "[$-en-US]0000")) &&
     DateValue('Roll in Date') <= DateAdd(DateValue("9/1/" & Text(Year(Today()) - If(Month(Today()) < 9, 1, 0), "[$-en-US]0000")), 1, TimeUnit.Years) - 1
     ), Text(Month(DateValue('Roll off Date')), "[$-en-US]00") & "/" & Text(Year(DateValue('Roll off Date')), "[$-en-US]0000")=months.Value ) ) ));

     

    If this reply can help you , you can click mark this reply as solution (Accept solution) which can help more people, thanks in advance! 

     

    Best Regards,

    Yueyun Zhang

     

     

     

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hello @v-yueyun-msft ,

     

    Thank you for your insights. However i am getting this result 😞

    ralmarism_0-1709804701362.png

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @v-yueyun-msft ,

     

    Just to update. it works now. I changed some "in" words into "off" then. I got this. 

    ralmarism_0-1709806895584.png

     

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 358 Most Valuable Professional

#2
11manish Profile Picture

11manish 214 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 185

Last 30 days Overall leaderboard