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

Sum a field on a gallery after filter

Hi,

 

I try to sum a field (lblQty * lblUnitP) that is in a gallert (Gallery5) into a label field outside the gallery.

Attached a screenshot.

 

The code in the lblUnitP field's Text = "R " & Text(ThisItem.UnitPrice,"[$-en-US]0,000.00")

The code in the lblSum (outside the gallery) Text = Sum(Value(lblQty.Text) * Value(lblUnitP.Text))

lblSum is showing 0.

 

What am I doing wrong?

 

 

8 REPLIES 8
xzDan
Level 8

Re: Sum a field on a gallery after filter

off the top of my head, what happens if you remove the R? ( = Text(ThisItem.UnitPrice,"[$-en-US]0,000.00"))

in case the R is messing it up

SoftSpot
Level: Powered On

Re: Sum a field on a gallery after filter

PA1.PNG

It is doing somethimg now, but wrong figure. It should sum the Qty * UnitP

xzDan
Level 8

Re: Sum a field on a gallery after filter

7841*4 = 31364 as you have.


The issue is you need to do

Sum(<Source>,Expression)

So try something like

Sum(<Your gallery name>, <Table Column for quantity> * <Table Column for price>)

Guessing here:

Sum(<Gallery>,Value(UnitQty) * Value(UnitPrice))

 

SoftSpot
Level: Powered On

Re: Sum a field on a gallery after filter

Tried everything so far:

Sum(Gallery5.AllItems, (Gallery5.AllItems.Qty) * (Gallery5.AllItems.UnitPrice))

Tried it without AllItems, above give me error on Qty and Unitprice (Invalid argument type. Expecting one of the following: Number, Text, Boolean. Above code is refrencing the sql database fields. I also tried referencing the 2 label fireld with value() function. Still no joy.

 

 

xzDan
Level 8

Re: Sum a field on a gallery after filter

No no, Gallery.AllItems is a table

 

For example, if I had a table Tbl1 with columns

{Quantity, Price}

 

And I set Gallery1's Items to Tbl1

 

The sum would be Sum(Gallery1.AllItems, Quantity*Price) - referencing the column names, not the controls in the gallery

 

--

Are you manually allowing for the user to change Quantity etc? Is it a text box or just a label?

SoftSpot
Level: Powered On

Re: Sum a field on a gallery after filter

No, this is only to dosplay data.

xzDan
Level 8

Re: Sum a field on a gallery after filter

Then the above suggestion should work I believe

Administrator
Administrator

Re: Sum a field on a gallery after filter

Thanks for posting in the community @SoftSpot. Are you still experiencing this issue? Can you review the above reply and update the thread if it was helpful? 

 

Thank you,

 

@TopShelf-MSFT 

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

PowerApps Monthly Community Call

Next Wednesday, August 21st at 8am PDT

Top Community Contributors for July 2019

Top Community Contributors for July 2019

Let's thank our top community contributors

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

FifthImage

Dynamics 365 and Power Platform April 2019 Release notes

Features releasing from April 2019 through September 2019!

SixthImage

Power Summit Australia 2019

August 20-23rd 2019

Users Online
Currently online: 19 members 4,190 guests
Please welcome our newest community members: