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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Sum function in PowerA...
Power Apps
Unanswered

Sum function in PowerApps recalculates based on the currently visible items in the gallery.

(0) ShareShare
ReportReport
Posted on by
hI Everyone
 

I HAVE A GALLERY WITH ITEMS PROPERTY WITH THE FOLLOWING

 

 
FirstN(
LastN(
Distinct(
Filter(
'Impact & Assessment Evaluations',
'Top IT Risk _Category '.Risk_name = VarTopItForBottomUp.Risk_name
),
Question
),
CountRows(
Distinct(
Filter(
'Impact & Assessment Evaluations',
'Top IT Risk _Category '.Risk_name = VarTopItForBottomUp.Risk_name
),
Question
)
) - (varCurrentPage - 1) * 4
),
4
)

 

I have a next button which is outside the gallery, when user clicks on it, the next four items will display

 

If(
varCurrentPage < RoundUp(
CountRows(
Distinct(
Filter('Impact & Assessment Evaluations','Top IT Risk _Category '.Risk_name = VarTopItForBottomUp.Risk_name
),
Question
)
) / 4,
0
),
Set(varCurrentPage, varCurrentPage + 1)
)

 

I have a previous button which is outside the gallery, when user clicks on it, the previous four items will display

 

 

If(
varCurrentPage > 1,
Set(
varCurrentPage,
varCurrentPage - 1
)
)


I have a label which is inside the gallery the gallery which shows the value of the impact

 

I have another label which is outside the gallery which shows the sum of values inside the gallery Label

 

Sum(
ForAll(
Gallery4.AllItems,
Value(Label5.Text)
),
Value
)


The problem Iam facing is when clicks on the next button the count of the sum which is done for the first 4 items is gone
and starting from the default as Zero

 

the sum resetting when navigating through pages in My gallery. the fact that the Sum function in PowerApps recalculates based on the currently visible items in the gallery. When you change pages, the visible items change, which resets the sum.

 

Could anyone please help me to fix the issue 

Categories:
I have the same question (0)
  • anandm08 Profile Picture
    1,936 Super User 2024 Season 2 on at

    hi @Danny_Dicaprio ,

    Initialize the Running Total Variable:

    • Add a variable to store the running total when the app starts or when a specific condition is met (e.g., navigating to the first page).

     

    Set(varRunningTotal, 0);
    Set(varCurrentPage, 1);
    ​

     

    Update the Running Total on Next Button Click:

     

    If(
     varCurrentPage < RoundUp(
     CountRows(
     Distinct(
     Filter('Impact & Assessment Evaluations', 'Top IT Risk _Category '.Risk_name = VarTopItForBottomUp.Risk_name),
     Question
     )
     ) / 4,
     0
     ),
     Set(varRunningTotal, varRunningTotal + Sum(Gallery4.AllItems, Value(Label5.Text))),
     Set(varCurrentPage, varCurrentPage + 1)
    )

     

    Update the Running Total on Previous Button Click:

     

    If(
     varCurrentPage > 1,
     Set(varCurrentPage, varCurrentPage - 1),
     Set(varRunningTotal, varRunningTotal - Sum(Gallery4.AllItems, Value(Label5.Text)))
    )

     

    Use a label outside the gallery to display the cumulative sum using the varRunningTotal variable.

     

    varRunningTotal

     

  • Danny_Dicaprio Profile Picture
    on at

    HI @anandm08 

     

    Thanks for the response, the formula in the next button is not working 

    It is not navigating to the next page 

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 545 Most Valuable Professional

#2
Haque Profile Picture

Haque 314

#3
Kalathiya Profile Picture

Kalathiya 234 Super User 2026 Season 1

Last 30 days Overall leaderboard