web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Sum Filter with 2 fiel...
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:
I have the same question (0)
  • TheRobRush Profile Picture
    11,128 Moderator on at

    try

    Sum(
    Filter(InventoryReceived,
     And(LotId=ThisItem.LotId, 
     Expiration=ThisItem.Expiration
     )
     ),
    QuantityRecieved)
  • ESCOFORMS Profile Picture
    10 on at

    Thank you for your response.

    However, this is the error I have when trying that

    ESCOFORMS_0-1684271651739.png

     

  • TheRobRush Profile Picture
    11,128 Moderator on at

    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

    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,128 Moderator on at

    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

    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.🤔

  • ESCOFORMS Profile Picture
    10 on at

    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)

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard