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 / Powerapps Calculation ...
Power Apps
Answered

Powerapps Calculation Problem

(1) ShareShare
ReportReport
Posted on by 147

Hello, everyone,

I have a problem with a calculation.

I habe 2 galleries, several checkboxes in each gallery (prices are stored).
Now I would like to carry out a calculation when selecting the checkbox (can be several in both galleries). This should be in a label field


Unfortunately I don't know how to calculate that

Categories:
  • WiZey Profile Picture
    3,023 Moderator on at

    Hello @memphis11 ,

     

    What do you want to calculate? What result are you looking for? Can you add more details so we can help you?

  • memphis11 Profile Picture
    147 on at

    My idea was:
    if I write a checkbox within a gallery (as I said, there can be several) this value in a collection
    This means I have at least one value from 2 galleries. I would like to calculate these values together (addition) and write the result in a label

    What information do you need exactly?

  • WiZey Profile Picture
    3,023 Moderator on at

    Let's presume your two collections.

     

    colA and colB are two collections with the following structure: 

     

    {
     Value: //Some number;
     Selected: //boolean
    }

     

    I'm going to assume "Value" is the number you want to add and "Selected" is if the checkbox is selected or deselected.

     

    To add every number that was selected in both collections, you can use the following formula:

     

    Sum(Filter(colA;Selected);Value) + Sum(Filter(colB;Selected);Value)

     

    However, you need to change the value of "Selected" whenever you click on the checkbox. You can do that easily by adding the following code in the "OnSelect()" of the checkbox:

     

    Patch(colA;ThisItem;{Selected:Self.Value})

     

    Is this helpful to you?

  • memphis11 Profile Picture
    147 on at

    Perfect, that looks good.
    I'll test it right away and give you feedback

  • memphis11 Profile Picture
    147 on at

    Hello,
    Unfortunately I can't do it: Here is my configuration:

    Gallery1:
    OnCheck: Collect(col_Model;ThisItem.Price);;


    Gallery2:
    OnCheck:Collect(col_Model2;ThisItem.Price);;


    Lable Field:
    Text: Sum(Filter(col_Modell;ThisRecord);Value) + Sum(Filter(col_Model2;ThisRecord);Value)


    In addition, there is the problem that the gallery does not write both values in the collection, but only one

  • Verified answer
    poweractivate Profile Picture
    11,078 Most Valuable Professional on at

    @memphis11 

     

    Like this:

     

    In the Text property of your Label, put this formula:

     

    Text(Sum(Gallery1.AllItems,If(Checkbox1_1.Value = true,Price,0)) + Sum(Gallery1_1.AllItems,If(Checkbox1.Value = true,Price,0)))

     

     

    (note: This simpler formula might also work, without the outer Text)

     

    Sum(Gallery1.AllItems,If(Checkbox1_1.Value=true,Price,0))+Sum(Gallery1_1.AllItems,If(Checkbox1.Value=true,Price,0))

     

     

     

    Working Example:

    sum_2_galleries.gif

     

     

    If you want some more detail let me know. I might also update this post with more details. 

     

    More detail:

     

    Screen1 OnVisible:

     

    ClearCollect(Collection1,{Price:1.23},{Price:4.56});ClearCollect(Collection2,{Price:7.89},{Price:0.12});
    

     

    To understand more about ClearCollect, check here:

    ClearCollect in Power Apps - docs.microsoft.com

     

     

    Gallery1_1 with Items Property set to Collection2

    Gallery1 with Items Property set to Collection1

     

    To understand more about Gallery check here:

    Gallery in Power Apps - docs.microsoft.com

     

     

    Both galleries can use the default Vertical template when you add them.

     

    If nothing is shown now, then: add an empty Screen called Screen2, and then toggle to Screen2 and back to Screen1. This is to update the collections. Now the Galleries will show, each gallery showing two records.

     

    To understand more about Screen and OnVisible, check here:

    Screen control in Power Apps - docs.microsoft.com

     

    Select Gallery1_1. Click the Edit icon on upper left of the Gallery. Insert a Checkbox so it appears in each row of the Gallery.

    Repeat this step for Gallery1

     

    Insert Label into Screen1. For this label, you put the formula at top of this post for the Text property.

     

    Sum(Gallery1.AllItems,If(Checkbox1_1.Value=true,Price,0))+Sum(Gallery1_1.AllItems,If(Checkbox1.Value=true,Price,0))

     

    To understand more about Sum, check here:

    Sum - Power Apps - docs.microsoft.com

     

    To understand more about If, check here:

    If - Power Apps - docs.microsoft.com

     

     

    Now you are done.

     

    Either preview the app and click the checkboxes to see it working, or hold down ALT on keyboard and click the checkboxes to live-preview the app.

     

    -------------------------------------------

    Working Sample msapp

     

    I have also attached a working sample msapp file app17.msapp if you would like to import a full, working example yourself for your convenience.

     

    To use the sample msapp attached, follow these steps:

     

    1) Download the msapp file attached to this post, to Desktop or a folder of your choice, by clicking on it from this post.

    2) Create a new, blank Power App Canvas App

    3) Go to File -> Open -> Browse

    poweractivate_0-1658256888824.png

     

     

    4) Navigate to location of .msapp file from Step 1, select it, and press the "Open" button.

    5) The working example msapp file should load

    6) You can try the full working example and also check the working formula and setup as well in the app.

     

    Check if it helps @memphis11 

  • Verified answer
    memphis11 Profile Picture
    147 on at

    Perfect, that's it...

     

    Thank you very much and have a nice evening

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 381 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 340

#3
WarrenBelz Profile Picture

WarrenBelz 187 Most Valuable Professional

Last 30 days Overall leaderboard