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

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Accumulation in collection (and calculation between colums in collection)

(0) ShareShare
ReportReport
Posted on by 128

I have a collection with these purchase figures (sorted in date order)...

"Remain" is a figure collected in another table, showing the QTY on stock...

jlkeas_0-1692098248381.png

I would like to accumulate the data in QTY per Material... (in a new column called "CUM_QTY")

Afterwards I would like a to add a new column called "Cur_remail" in which I would like to make a calculation, showing how many QTY of the given purchase that is still on stock... 

(in excel my formular in H2 is "=MAX(IF(D2>G2;C2;D2-G2+C2);0)", but don't know how to apply it to Power Apps")

jlkeas_2-1692098634082.png

 

Can anyone help me to get these 2 calculations into my gallery/collection?

 

wkr Jørgen

Categories:
I have the same question (0)
  • Verified answer
    v-bofeng-msft Profile Picture
    on at
    Re: Accumulation in collection (and calculation between colums in collection)

    Hi @jlke-as ,

     

    I assume there is a collection:

    ClearCollect(
     TheCollection,
     {Material:"A",Date:Date(2023,5,21),QTY:10,Remain:15},
     {Material:"B",Date:Date(2023,5,20),QTY:10,Remain:12},
     {Material:"C",Date:Date(2023,5,19),QTY:20,Remain:25},
     {Material:"A",Date:Date(2023,5,18),QTY:30,Remain:15},
     {Material:"C",Date:Date(2023,5,17),QTY:50,Remain:25},
     {Material:"A",Date:Date(2023,5,16),QTY:20,Remain:15},
     {Material:"B",Date:Date(2023,5,15),QTY:20,Remain:12}
    );

     

    You could try:

    AddColumns(
    AddColumns(
     TheCollection As A,
     "CUM_QTY",
     A[@QTY]+Sum(Filter(TheCollection,Material=A[@Material] && Date>A[@Date]),QTY)
    ),
    "Cur_remain",
    Max(If(Remain>CUM_QTY,QTY,Remain-CUM_QTY+QTY),0)
    )

     

    Best Regards,

    Bof

  • jlke-as Profile Picture
    128 on at
    Re: Accumulation in collection (and calculation between colums in collection)

    Hi Bof...

    Perfect... You have saved my day... 😉

    Could you please explain the "As A" in you solution?

    wkr Jørgen

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 624 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 381 Super User 2025 Season 2

#3
developerAJ Profile Picture

developerAJ 225

Last 30 days Overall leaderboard