cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sasrsc
Resolver II
Resolver II

2 Tables, get a group by count on the detail table and add it to the summary table....

I am building a poc and I have a summary table called "events" and then a detail table called "attendee".
They are both SP lists in this poc.

I want to get the count of attendees by event and append that value to the events table. I have achieved that in a 3 step process.

Step

Purpose

Code

1

Create Collection and Group By total on the Attendee table.

ClearCollect(EventCounts1,AddColumns(GroupBy(Attendee,"Title","ID"),"Count",CountRows(ID))

);

2

Drop the GroupedColumn info (don't need it) 

ClearCollect(

    EventCounts2,

    DropColumns(

        EventCounts1

        ,"ID")

)

3

Join Together (attcount is the column added to the Events table)

ClearCollect(EventCounts3,

    AddColumns(Events,"AttCount",LookUp(EventCounts2,EventID=EventCounts2[@Title],Count))

);


My questions are ...
1) Could I reduce this to a single step? If so how?
2) Can you achieve this without creating a collection and simply append to the Events table as I just need that "attcount" column in the UI to show a count (I am never manipulating the value)


1 REPLY 1
Jeff_Thorpe
Super User
Super User

I am assuming that you are using a data table and that there is a field called EventID on the Attendee list that correlates to the ID field on the Events list.

Try adding this formula to Items property of the Data Table.

AddColumns(Events ,"AttCount",CountIf(Attendee, EventID = Events[@ID] ))

 



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (1,962)