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 / Group by Year and Mont...
Power Apps
Unanswered

Group by Year and Month on Browse Gallery

(0) ShareShare
ReportReport
Posted on by 519

I have an app that has a browse gallery setup with a search functionality that works really well.  Below is the code in the Items property.

SortByColumns(Search('Initial Incident Notification',SearchBox.Text,"ImmediateActionstobetaken", "DescriptionofIncident"),"Created",Descending)

 

The gallery above basically shows three fields within the view:

The Form ID no., the description of the incident and the submitter (created by) field. 

I would like to include an option to group records on this same screen by "Year" and "Month" within the year.  Additionally, there is a column called "Investigation Status" which would greatly assist users with reporting.  I already created two columns in the SharePoint list called year and month and used a formula to extract same based on the Created date as these fields were not there before.  I am not sure how to include this in the above formula of the items property, (Group by Year, Month and Investigation Status) nor am I sure if this is the best approach. 

Users of the app would like to see submissions grouped by year, month and Investigation Status, similar to how you can group in a SharePoint list.  This would greatly help when they have to update records.  Any guidance and assistance appreciated.

Categories:
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @joshieboy 

    If you are referring to having literal grouping by Year Month and status in your Gallery, you are really referring to a nested gallery.  And...the limit is one nested Gallery.  So, you will need to decide the levels that you want and how to nest.

    Grouping by the columns is not an issue as much as the display of this information will be.  You actually don't even need the extra columns you created in order to do the grouping.  But, it's really that display thing that is going to be a problem for you.

    So ask yourself if some other options are available to you to aid in displaying the info, such as, can you utilize a dropdown to select Years, Months or Status?  That would take you away from the need for grouping and nesting and more to simply filtering.  But, I don't know your ultimate interface requirements, so these are just suggestions.

     

    I hope this is helpful for you.

  • joshieboy Profile Picture
    519 on at

    Hi @RandyHayes - this is really good info.  Thanks.  The dropdown is actually an excellent idea.  I didn't think of it before.  Can you walk me through how to achieve this?  Thanks.

    When you go to the gallery all of the records are being displayed in one go, so the filtering would be nice as different users of the app have different needs.  Some would be interested in records for a particular year, while others based on the status of the record.  One other field of interest is Investigation Level which shows the severity of the record.  So basically once I can setup from the gallery records by:

    • Year
    • Month
    • Investigation Status
    • Investigation Level

    This will make the experience better for users.

  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at
    • Have 4 Combo Box control for each filter
    • In Gallery Items property
    With({sData:
     Filter(
     'Initial Incident Notification',
     IsBlank(InvestigationStatus_Filter.SelectedItems.Value) || IsEmpty(InvestigationStatus_Filter.SelectedItems)|| 'Investigation Status'.Value= InvestigationStatus_Filter.Selected.Value, //Filter 1
     IsBlank(InvestigationLevel_Filter.SelectedItems.Value) || IsEmpty(InvestigationLevel_Filter.SelectedItems)|| 'Investigation Level'.Value= InvestigationLevel_Filter.Selected.Value, //Filter 2
    	 IsBlank(SubmittedOnYear_Filter.SelectedItems.Value) || IsEmpty(SubmittedOnYear_Filter.SelectedItems)|| Year(SubmittedOn.Value) = SubmittedOnYear_Filter.Selected.Value, //Filter 3
    	 IsBlank(SubmittedOnMonth_Filter.SelectedItems.Value) || IsEmpty(SubmittedOnMonth_Filter.SelectedItems)|| Month(SubmittedOn.Value) = SubmittedOnMonth_Filter.Selected.Value //Filter 4
     )
     }
    )

     

    Update the control and field names (Names are just guessed)

  • joshieboy Profile Picture
    519 on at

    Hi @StalinPonnusamy - thanks for the feedback.

    I am not sure how to properly implement this based on what you said above.

    As a test I created one combo box for Investigation Status and for the Items property of that combo used what you had above using my field name:

     

    With({sData:
    Filter(
    'Initial Incident Notification',
    IsBlank(InvestigationStatus.SelectedItems.Value) || IsEmpty(InvestigationStatus.SelectedItems)|| 'Investigation Status'.Value= InvestigationStatus.Selected.Value, //Filter 1
    )
    }
    )

    I'm getting errors:  

    The function filter has some invalid arguments

    Unexpected characters.  characters are used in the formula in an unexpected way.

    Not sure how your above formulas should be implemented.  Im also assuming that the below precedes each of the filters on the respective combo boxes?  Any additional guidance appreciated.

    With({sData:
     Filter(
     'Initial Incident Notification',

     

  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at

    Hi @joshieboy Sorry, my post was not helpful.

     

    To simplify, here is the example with one filter

     

    With(
     {
     sData: Filter(
     'Issue tracker',
     IsBlank(ComboBox1.SelectedItems.Value) || IsEmpty(ComboBox1.SelectedItems) || Priority.Value = ComboBox1.Selected.Value
     )
     },
     sData
    )

     

     

    Example with One filter

    StalinPonnusamy_0-1627079204888.png

    Two FIlters:

    With(
     {
     sData: Filter(
     'Issue tracker',
     IsBlank(ComboBox1.SelectedItems.Value) || IsEmpty(ComboBox1.SelectedItems) || Priority.Value = ComboBox1.Selected.Value,
     IsBlank(DatePicker1.SelectedDate) || IsEmpty(DatePicker1.SelectedDate) || 'Date reported'= DatePicker1.SelectedDate
     )
     },
     sData
    )

     

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @joshieboy 
    Sure thing.  So for the 4 different filters you want, you will need to decide if your design will provide filtering by multiple items (i.e. multiple Status, multiple month, etc.) or if you will be filtering by single picks.  This will determine if you will use a dropdown control or a combobox control.  Either is fine, but the combobox will introduce some delegation concerns - so this will also depend on your data source size.

     

    Essentially, if you have dropdowns like so:

    Year dropdown named drpYear with an Items property of ForAll(Sequence(x), startYear + Value)  This is somewhat static and not related to the data in regard to years, but it is quick.  Replace the x with the number of years to make available to filter and then startYear with the starting year number.

     

    Month dropdown named drpMonth with an Items property of ForAll(Sequence(12), {Value: Value, MonthName: Last(FirstN(Calendar.MonthsShort(), Value)).Value}) This will give you a dropdown with all the months and their numeric and descriptive names.

     

    Investigative status and Level you're kind of on your own for with the Items property as I don't know them, but they can be as simple as ["Status1", "Status2", etc..]  Let's call them drpStatus and drpLevel.

     

    Set the AllowEmptySelection property of all of the dropdowns to true and then set the Default property of all of them to Blank()

     

    Now for your Gallery, the filter would be this:

    SortByColumns(
     Search(
     Filter('Initial Incident Notification',
     (IsBlank(drpYear.Value) || yourYearColumn = drpYear.Value) &&
     (IsBlank(drpMonth.Value) || yourMonthColumn = drpMonth.Value) &&
     (IsBlank(drpStatus.Value) || yourStatusColumn = drpStatus.Value) &&
     (IsBlank(drpLevel.Value) || yourLevelColumn = drpLevel.Value)
     ),
     SearchBox.Text, 'ImmediateActionstobetaken', 'DescriptionofIncident'
     ),
     "Created", Descending
    )

     

    That will be all you need for the above scenario.  If you want multiple select, then there are some changes to put in place, but if not, the above will give you what you are looking for.

     

    See how that gets things for you.

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 236 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 188 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 130

Last 30 days Overall leaderboard