When we run FetchXML queries on Power Pages Liquid code we get the results as a single table data structure. But sometimes it would be useful if we could group the results by some of the fields on the data set before rendering the items on the page, so we can use that for some calculations or to render data in a structure that is not a table structure or flat data structure display, like a hierarchy view for instance.
We can do it easily by using the group_by Liquid filter and the correct syntax.
Example scenario
For example, for the following data set, where we have a table named submissions and each submission is assigned to an Account:
If we want to render the following page, with the Account names as h2 heading elements, and below it an unordered list (ul) tag with the submissions listed as list item (li) items for each account:
Given that we have the following FetchXml query on the page or WebTemplate:
{% fetchxml fetch_submissions %}
<fetch...
Source link
More About This Author
-
SharePoint and Office 365 Consultant/Developer always trying to get the best from Microsoft stack (Microsoft 365/Azure/Power Platform and related stuff).
Living in Ireland since 2018, I had previously worked in Brazil as a consultant/developer for Office 365, SharePoint and related technologies for almost 10 years.
Array
- Modern Workplace7 September 2024Power Pages: Use a custom Rich Text Files table to store images (and avoid exposing the full msdyn_richtextfiles table)
- Modern Workplace2 September 2024Power Pages: Display images from a Rich Text field using Liquid
- Modern Workplace17 August 2024Hiding the ‘Forms’ button in a SharePoint list view using List Formatting
- Modern Workplace10 August 2024Power Pages, FetchXML and Liquid: Group results by Lookup fields