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 / Trying to combine cert...
Power Apps
Answered

Trying to combine certain records in a dataset

(0) ShareShare
ReportReport
Posted on by 380

I have a Powerapp and a Gallery presenting meter readings from a Sharepoint List

 

I am trying to group on a column called "auth" and then sum the difference between the min and max reading to get water usage for a period in time (between 2 datepickers)

 

Consider the attached screenshot:
In the 4th and 5th record we have the following values in the auth column:

621563

621563;621564

 

both auths are owned by the same Client so I want to add the usage for both records but only show the combined auths value which in this case is 621563;621564

 

so the logic is: If the auth value contains 2 or more auths AND 1 of those auths exists as a single auth on a seperate record then combine and only show the multiple auths value

 

so if we had:

123456

123457;123459l;123456

876543;872514;887665

887665

 

I want to display only this:

123457;123459l;123456

876543;872514;887665

 

hope I have explained myself well enough 🙂

thanks

usage.png
Categories:
  • VishalJhaveri Profile Picture
    1,169 Moderator on at
    ClearCollect(
     CombinedAuths,
     Filter(
     YourSharePointList,
     CountRows(
     Filter(
     YourSharePointList,
     CountRows(
     Filter(
     Split(
     ThisItem.Auth, // Split the auth value into an array of auths
     ";"
     ),
     AuthColumn = Result
     )
     ) = 1 // Check if any of the auths exist as a single auth on another record
     )
     ) > 0 // Check if there are multiple auths and at least one matches a single auth elsewhere
     )
    );
    
    // Display the combined auth values in your Gallery
    Items = CombinedAuths

    Please try this if it works.

  • bobgodin Profile Picture
    380 on at

    @VishalJhaveri thanks a lot for this....just a bit unsure where to put the ClearCollect statement...I tried in the OnVisible property of the screen but it didn't like it - "CountRows is not supported" and "ThisItem isn't recognised see screenshot - thanks again

    clearcollect.png
  • WarrenBelz Profile Picture
    156,748 Most Valuable Professional on at

    Hi @bobgodin ,

    This structure is working on my end with  a collection the same as the data you posted

    With(
     {
     _Records:
     AddColumns(
     SPList,
     _Auths,
     Split(
     Auth,
     ";"
     ).Value
     )
     },
     With(
     {
     _OneItem:
     Filter(
     _Records,
     CountRows(_Auths) = 1
     ), 
     _MoreItems:
     Filter(
     _Records,
     CountRows(_Auths) > 1
     )
     },
     Ungroup(
     Table(
     {Value: _MoreItems},
     {
     Value: 
     Filter(
     _OneItem,
     !(
     Auth in 
     Ungroup(
     _MoreItems,
     _Auths
     ).Value
     ) 
     )
     }
     ),
     Value
     )
     )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • Verified answer
    bobgodin Profile Picture
    380 on at

    @WarrenBelz thanks heaps Warren - I think it is doing the job perfectly - had to add a comma and changed Auth to auth but otherwise spot on - will check deeper to make sure....

  • WarrenBelz Profile Picture
    156,748 Most Valuable Professional on at

    Thanks @bobgodin ,

    Not sure where the missing comma is - I copied the code straight from the working version in my test app - I will fix if necessary if you point it out.

  • bobgodin Profile Picture
    380 on at

    hi @WarrenBelz  the comma I added was just after MeterReadings (mySPList):

    AddColumns(
    MeterReadings,
    _Auths,

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 345 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 312

#3
Mohsin Ali Profile Picture

Mohsin Ali 252

Last 30 days Overall leaderboard