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 function in PowerA...
Power Apps
Unanswered

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.

(0) ShareShare
ReportReport
Posted on by

I HAVE A GALLERY WITH ITEMS PROPERTY WITH THE FOLLOWING

 

 
FirstN(
LastN(
Distinct(
Filter(
'Impact ',
'Risk _Category '.Risk_name = VarTop.Risk_name
),
Question
),
CountRows(
Distinct(
Filter(
'Impact ,
'Risk _Category '.Risk_name = VarTop.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 ,'Top IT .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)
  • Verified answer
    WarrenBelz Profile Picture
    153,034 Most Valuable Professional on at

    Hi @Danny_Dicaprio ,

    Just did a test here using a similar structure test list - apart from cutting down the Items to

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

    and the Label to

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

    with the other to the same, it worked perfectly as below.

    pagination.gif

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

     

  • Danny_Dicaprio Profile Picture
    on at

    Hi @WarrenBelz 

     

    Thanks for the response but still Iam facing the same issue 

     

     

    I have updated the items gallery and the label

     

    Spoiler (Highlight to read)

     

     

    when I clicks on the Next button the above label which shows the count 11 is getting back to  default 

    Spoiler (Highlight to read)

     

     

     

  • WarrenBelz Profile Picture
    153,034 Most Valuable Professional on at

    @Danny_Dicaprio ,

    The Sum seems to be correct based on the figures at the right of the items - what is not working ?

  • Danny_Dicaprio Profile Picture
    on at

    Hi @WarrenBelz 

     

    Thanks for the response

     

    when I click on the next button the previous sum is not getting calculated along with the new sum

     

    Iam looking for the final sum in the label from all the items 

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

    in the label outside the gallery it is showing the count of the last 4 items in the gallery , Not the previous one 

     

     

  • WarrenBelz Profile Picture
    153,034 Most Valuable Professional on at

    Hi @Danny_Dicaprio ,

    That is not going to work with what you are doing as Sum(Gallery . . .) will only add what is displayed by the Gallery Items. The problem also is that there is no control over how many times or in what order the user clicks the two buttons, so doing some sort of progressive Variable is problematic.

  • Danny_Dicaprio Profile Picture
    on at

    HI @WarrenBelz 

     

    Thanks for the response

     

    so if u could see my screenshot for all the responses choosed by the user I have value corresponding to that column in the dataverse table 

     

    Danny_Dicaprio_0-1719376032120.png

     

     

    Is there is any way we could do the calculation without using the label inside the gallery 

  • WarrenBelz Profile Picture
    153,034 Most Valuable Professional on at

    @Danny_Dicaprio ,

    You need to either use the Label or a field in the Items. If not, you would need a separate filter to what is displayed in the Gallery and do a sum on that.

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 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard