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
Power Apps Africa Challenge 2022

Power Apps Africa Challenge

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

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Government Carousel

New forum: GCC, GCCH, DoD - Federal App Makers (FAM)

In response to the unique and evolving requirements of the United States public sector, Microsoft has created Power Apps US Government.

Users online (4,394)