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 / checkbox in gallery
Power Apps
Answered

checkbox in gallery

(0) ShareShare
ReportReport
Posted on by 559

Hi all,

I have two galleries(first one is Phase gallery and the second one is final Phase gallery). When the checkbox is clicked in the first gallery it will add rows in the second gallery based on the count of items in the work product(For e.g. when the checkbox near the "Design" is selected in the first gallery and the work product (combo box) is having 4 items, 4 rows will be added in the second gallery below). I have a requirement when the user clicks on the checkbox in the First Phase gallery rows will be added. When user uncheck the checkbox before saving it must clear the added rows from the second gallery below. 

In the second gallery (for design if it has 4 rows and when user deletes all the 4 rows for the design phase by checking the checkbox in the second gallery  it must also uncheck the checkbox in the first Phase gallery, and when only 2 is deleted of 4 rows it must not uncheck the checkbox in the first Phase gallery).

the code for the first gallery phase(oncheck of the checkbox).

Set(countitems,0); //this is the variable set to count items for work product.

Set(countitems,Sum(Count Rows(ComboBox6_5.Selected Items),count items)); //this count the items in work product based on the checkbox checked for each phase.
ForAll(Sequence(count items) As SequenceNumber, // this add rows based on the checkbox selected in the second gallery.
Collect(
colFinalPhase,      //colFinalPhase is the collection used in the items property of the second below gallery.
{
ID: Last(colFinalPhase).ID + 1,
'Phase ID': varNewPhase,
'Project Name': prjnames_3.Selected.ProjectName,
Phase: Title2_4.Text,
'Work Product/Process': Last(
FirstN(
ComboBox6_5.Selected Items,
SequenceNumber.Value
)
).'Work Product/Process'
}
)
);

Any help/suggestion on this?

Categories:
I have the same question (0)
  • v-jefferni Profile Picture
    on at

    Hi @Uthhra ,

     

    Please check my steps:

    1. You need an additional column of number to store the number of checked phrase:

    vjefferni_4-1705648043279.png

     

    2. OnCheck of Gallery1 you need to update the Number column to save the number as well.

    Patch(colItems,ThisItem,{Number:CountRows(ComboBox1.SelectedItems)});

    vjefferni_5-1705648078847.png

     

    3. CheckBox Default bound to the condition: ThisItem.Number > 0

     

    4. OnUncheck of Gallery1, delete items of current phrase and also update the number to 0:

    vjefferni_6-1705648114820.png

     

    5. OnCheck of Gallery2:

    Remove current item from colFinalPhase but also update Number to the number of items with the same phase in colFinalPhase:

    vjefferni_7-1705648146934.png

     

    Best regards,

  • Sri Profile Picture
    559 on at

    @v-jefferni 

    Both my gallery items comes from a different SharePoint list. what is with the new number column. Can you explain me what is being done.

  • v-jefferni Profile Picture
    on at

    Hi @Uthhra ,

     

    When you use phases from a SP list to populate in Phase Gallery Items, you can add an additional number column:

    ClearCollect(colPhases, AddColumns(SPlist, "Number", 0))

     

    in the following steps, replace colItems with colPhases is enough. The number column is used for saving the number of work products for each phase.

     

    Best regards,

  • Sri Profile Picture
    559 on at

    @v-jefferni 

    I have added screenshot for the items property for the phases gallery. As you asked to add number column for the work product, I cannot give constant of only 4 numbers. it will vary for each phase. for 1 phase only 2 will be there, for another phase 5 or 6 will be there. Without giving definite values is there any other way?

  • v-jefferni Profile Picture
    on at

    Hi @Uthhra ,

     

    The initial numbers are 0 for all phases in phase Gallery. When you selecting work products in Combo box, the number will update (see step2) based on the number of selected work projects.

     

    OnVisible of the screen, create a collection for the phases and add a number column:

    ClearCollect(colPhases, AddColumns(Sort(Distinct(PhaseNames, Phase), Value), "Number", 0))

    The formula of phases Gallery Items:

    colPhases

     

    Best regards,

  • Sri Profile Picture
    559 on at

    @v-jefferni 

    For thw first Phases gallery can I use checkbox and the for the gallery 2 can I use icon instead of checkbox

  • Sri Profile Picture
    559 on at

    @v-jefferni 

    For the first Phases gallery can I use checkbox and the for the gallery 2 can I use icon instead of checkbox

  • v-jefferni Profile Picture
    on at

    Hi @Uthhra ,

     

    If using icons than Check boxes in new work projects Gallery, you can move the formulas in step 5 from OnCheck to OnSelect of the icon.

     

    Best regards,

  • Sri Profile Picture
    559 on at

    @v-jefferni 

    If I write this On visible I am getting an error. ClearCollect(colPhases, AddColumns(Sort(Distinct(PhaseNames, Phase), Value), "Number", 0))

    The function sort and distinct has invalid arguments.

  • v-jefferni Profile Picture
    on at

    Hi @Uthhra ,

     

    I use PhaseNames but the data source on you end should be Phasenames

    ClearCollect(colPhases, AddColumns(Sort(Distinct(Phasenames, Phase), Value), "Number", 0))

     

    Best regards,

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

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard