Skip to main content
Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Unanswered

Sum Filter with 2 fields matching

(0) ShareShare
ReportReport
Posted on by 10

Hi everyone.

I am developing a PowerApps that does inventory management for products with LOT and EXPIRATION.

 

Currently I am stuck on an issue for displaying a live count of how many of a certain product we have.

In my Gallery that is linked with my table:
Sum(Filter(InventoryReceived,LotId=ThisItem.LotId),QuantityRecieved)

 

works like
Sum(Filter(Table,Column=ThisItem.Column),sum_this_column_if_match)

 

The issue is that that formula only gives me the SUM if the LOT matches the current item on the gallery. I would like it to match both LOT + EXPIRATION in the case of the possibility of receiving same LOT different EXP products.

I have tried adding the additional condition in the Filter formula, but it doesn't work since EXP column is a date? or something like that.

Sum(Filter(InventoryReceivedLotId=ThisItem.LotId, Expiration=ThisItem.Expiration),QuantityRecieved)
does not work and neither does the SUM+FILTER for expiration by itself
Sum(Filter(InventoryReceived, Expiration=ThisItem.Expiration),QuantityRecieved)

Delegation warning. May not work on large sets.
(my table only has 5 rows)

How can I get my total counts with both filters?

Here is a sample table

InventoryReceived

idnametestLotIdExpirationQuantityReceived
1BOBFlu A TestSNIR-2441/1/202010
2BOBFlu A TestUFFS-2005/6/20235
3BOBFlu A TestSNIR-2449/9/19996
4BOBFlu A TestSNIR-2441/1/202020
Categories:
  • ESCOFORMS Profile Picture
    10 on at
    Re: Sum Filter with 2 fields matching

    Thank you for your help @TheRobRush

    I was able to get my sum to work by converting to text the expiration date like so 

    Sum(Filter(InventoryReceived,And(LotId = ThisItem.LotId),(Text(Expiration) = Text(ThisItem.Expiration))),QuantityReceived)
  • ESCOFORMS Profile Picture
    10 on at
    Re: Sum Filter with 2 fields matching

    It was varchar(25) before -

    I had changed it into an (int) and refreshed the database to try out all variations of the methods above however I am still getting a blank text output for some reason.

    Fixed the typo as well on all ends for received spelling 😅

    I did a IsNumeric(ThisItem.QuantityReceived)

    to test if it was a number, which I got true for all fields.

    ESCOFORMS_0-1684287598560.png

     

    When I do ThisItem.QuantityReceived I get a direct number shown, but when plugging in the whole formulas needed to add to combine the LOT/EXP combo, it goes blank.🤔

  • TheRobRush Profile Picture
    11,121 Super User 2025 Season 1 on at
    Re: Sum Filter with 2 fields matching

    Ah yah there was an extra comma, apologies. What kind of column is QuantityRecieved, because if it is just a number column, the above code shoul return a number. If its text you might need to change to

    Sum(
    AddColumns(
    Filter(InventoryReceived,
     And(LotId=ThisItem.LotId, 
     Expiration=ThisItem.Expiration
     )
     ), 
    "qtyRec",Value(QuantityRecieved)),
    qtyRec)
  • ESCOFORMS Profile Picture
    10 on at
    Re: Sum Filter with 2 fields matching

    That exact code gives me 

    ESCOFORMS_0-1684273722501.png


    I figured maybe it is because of the extra comma at

    Sum(
    AddColumns(
    Filter(InventoryReceived,
     And(LotId=ThisItem.LotId, 
     Expiration=ThisItem.Expiration
     )
     ), <-- I REMOVED THIS COMMA TO MAKE REMOVE THE ERROR
    ,"qtyRec",QuantityRecieved),
    qtyRec)

     
    But then it returns an blank value with no text at all.

  • TheRobRush Profile Picture
    11,121 Super User 2025 Season 1 on at
    Re: Sum Filter with 2 fields matching

    Here, try it this way

    Sum(
    AddColumns(
    Filter(InventoryReceived,
     And(LotId=ThisItem.LotId, 
     Expiration=ThisItem.Expiration
     )
     ),
    ,"qtyRec",QuantityRecieved),
    qtyRec)
  • ESCOFORMS Profile Picture
    10 on at
    Re: Sum Filter with 2 fields matching

    Thank you for your response.

    However, this is the error I have when trying that

    ESCOFORMS_0-1684271651739.png

     

  • TheRobRush Profile Picture
    11,121 Super User 2025 Season 1 on at
    Re: Sum Filter with 2 fields matching

    try

    Sum(
    Filter(InventoryReceived,
     And(LotId=ThisItem.LotId, 
     Expiration=ThisItem.Expiration
     )
     ),
    QuantityRecieved)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 1