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