cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Jumpa
Level: Powered On

RowsCount inside Gallery filtered by selected item

I've a table "Atable" and inside it a field named orderID that is a n-1 relationship to the table Orders.

I'm trying to count items for each order, then filter by order id.

So I'd like the following result:

 

Order1 - 5

Order2 - 3

Order3 - 0

The order id is inside the row of a gallery and I've to show the count on the row.

 

countRows(
    Filter(
        Atable;
        Order.ID = ThisItem.ID
    )
)

This warns me about delegation, so it's not ok.

So I thought: inside onVisible callback I can create a view that contains two fields: "OrderID" and "count".

How can I write the corresponding formula for:

 

SELECT orderID, COUNT(*)
FROM Atable;
GROUP BY orderID;

Many thanks in advance.

2 REPLIES 2
mdevaney
Level 8

Re: RowsCount inside Gallery filtered by selected item

More information is needed here. What datasource is ATable coming from? What type of column is Order.Id? If in SharePoint is Order.Id a LookUp column?
v-siky-msft
Level 8

Re: RowsCount inside Gallery filtered by selected item

Hi @Jumpa ,

 

What is the data source of Atable? CDS entity or SQL?

How much the data is there?

which table is the data source of Gallery, the table Orders right?

 

You can use collections to create a view, and group from "OrderID" by GroupBy function, and calculate the "Count".

Try to put the following formulas to OnVisible property of Screen.

 

ClearCollect(colorder, AddColumns(Atable,"OID",Order.ID));  /* add a text OID column */
ClearCollect(Coltotal, GroupBy(colorder,"OID","total")); /* group from OID */
ClearCollect(Colcount, AddColumns(Coltotal,"Count",CountRows(total))) /* add a Count column */

Then, add a label to gallery, set Text property as below:

 

LookUp(Colcount,OID=ThisItem.ID).Count

 

Please take a try, and check if it satisfies your needs.

Best regards,

Sik

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

Top Kudoed Authors
Users Online
Currently online: 222 members 4,004 guests
Please welcome our newest community members: