cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
isma_ept1991
Frequent Visitor

group by with sum and count in sharepoint list

Hi guys!!

I can't move forward

I'm trying to SUM and Count in a GroupBy, with SharepintLists.

 

In SQL the query shoud be like that:
select ROUND.ID, count(QUESTION.Id),sum(QUESTION.Time)
from ROUND r
inner join QUESTION s on ROUND.Id=QUESTION.IdRound
where QUESTION.result=true
group by ROUND ID

 

I tried to put the results into a Gallery,
Now i got at ITEMS-> GroupBy(Filter(QUESTION,result=true),"ID","Group1")
and into the gallery i put a label-> CountRows(ThisItem.Group1)

How can I add one label for COUNT and other label for SUM??

1 ACCEPTED SOLUTION

Accepted Solutions
WarrenBelz
Super User
Super User

Hi @isma_ept1991 ,

Using your field names provided - something like this

AddColumns(
   GroupBy(
      Filter(
         QUESTION,
         result=true
      ),
      "ID",
      "Group1"
   ),
   "CountItems",
   CountRows(Group1),
   "SumItems",
   Sum(Group1,Time)
)

 

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.

View solution in original post

3 REPLIES 3
WarrenBelz
Super User
Super User

Hi @isma_ept1991 ,

Using your field names provided - something like this

AddColumns(
   GroupBy(
      Filter(
         QUESTION,
         result=true
      ),
      "ID",
      "Group1"
   ),
   "CountItems",
   CountRows(Group1),
   "SumItems",
   Sum(Group1,Time)
)

 

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.

Many thanks!!
 About this function, how could i join this table to another table and get a new column from that table?

 

example.PNG

@isma_ept1991 ,

Note this is free-typed, but you will get the idea - your Count would not alter, but to get the Time total from List B, something like this

AddColumns(
   GroupBy(
      AddColumns(
         Filter(
            QUESTION,
            result=true
         ),
         "bTime",
         Lookup(
            TableB,
            IdTableA=ID
         ).Time
      ),
      "ID",
      "Group1"
   ),
   "CountItems",
   CountRows(Group1),
   "SumItems",
   Sum(Group1,bTime)
)

 

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.

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Top Kudoed Authors
Users online (2,597)