cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Rob_LVT
Frequent Visitor

Using ForAll to create multiple Collections

Good evening!

 

I have an idea that I'd like to implement, but I've been trying to figure how to do it.

 

I have an app that runs without a connection using collections and the save/load data functions. To save space, I want the user to choose which of the larger datasets they pull in so I don't eat up a bunch of space needlessly on their devices.

 

I have a gallery with 10 items manually listed in the items property and check boxes on each item. I added a button beneath so that when the user selects everything they want to retain for offline use, they can download all the data at once. Each item has it's own table in a SQL database that I would like to pull into separate collections, if checked. 

 

Say I have multiple items checked, how do I create multiple collections and fill them from multiple sources?

1 ACCEPTED SOLUTION

Accepted Solutions
v-bofeng-msft
Community Support
Community Support

Hi @Rob_LVT :

Do you want to update multiple collections with multiple data sources through the check box in the gallery?

First of all, thanks for @WarrenBelz 's solution.

Secondly,my solution uses nested If and swith functions,I've made a test for your reference:

My data source:

'List A' (SharePoint List)

'List B'(SharePoint List)

'[dbo].[Table_2]'(SQL Sever Table)

1\Add a gallerycontrol

Items:

 

["List A","List B","[dbo].[Table_2]"] /*Use the table composed of data source names as the data source of the gallery*/

 

2\Add a check box control(Checkbox2) into this gallery

OnSelect:

 

If(
    Checkbox2.Value, /*Determine the status of the current checkbox*/
    Switch(  /*Determine the currently selected record*/
        ThisItem.Value, 
        "List A",
        ClearCollect(    /*Update collection,collection1/2/3 is my custom collection*/
            collection1,  
            'List A'
        ),
        "List B",
        ClearCollect(
            collection2,
            'List B'
        ),
        "[dbo].[Table_2]",
        ClearCollect(
            collection3,
            '[dbo].[Table_2]'
        )
    ),    Switch(    /*if Checkbox2.Value is false, then clear the specific collection*/
        ThisItem.Value,
        "List A",
        Clear(
            collection1
        ),
        "List B",
        Clear(
            collection2
        ),
        "[dbo].[Table_2]",
        Clear(
            collection3)
    )
)

 

1.jpg

Best Regards,

Bof

 

 

View solution in original post

2 REPLIES 2
WarrenBelz
Super User III
Super User III

Hi @Rob_LVT ,

Good Afternoon (Saturday 12:30) here.

The approach I would recommend is to run each off the OnChange of the CheckBoxes and LoadData into a Collection as it is checked. If unchecked, you could clear the collection.

 

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.

 

 

v-bofeng-msft
Community Support
Community Support

Hi @Rob_LVT :

Do you want to update multiple collections with multiple data sources through the check box in the gallery?

First of all, thanks for @WarrenBelz 's solution.

Secondly,my solution uses nested If and swith functions,I've made a test for your reference:

My data source:

'List A' (SharePoint List)

'List B'(SharePoint List)

'[dbo].[Table_2]'(SQL Sever Table)

1\Add a gallerycontrol

Items:

 

["List A","List B","[dbo].[Table_2]"] /*Use the table composed of data source names as the data source of the gallery*/

 

2\Add a check box control(Checkbox2) into this gallery

OnSelect:

 

If(
    Checkbox2.Value, /*Determine the status of the current checkbox*/
    Switch(  /*Determine the currently selected record*/
        ThisItem.Value, 
        "List A",
        ClearCollect(    /*Update collection,collection1/2/3 is my custom collection*/
            collection1,  
            'List A'
        ),
        "List B",
        ClearCollect(
            collection2,
            'List B'
        ),
        "[dbo].[Table_2]",
        ClearCollect(
            collection3,
            '[dbo].[Table_2]'
        )
    ),    Switch(    /*if Checkbox2.Value is false, then clear the specific collection*/
        ThisItem.Value,
        "List A",
        Clear(
            collection1
        ),
        "List B",
        Clear(
            collection2
        ),
        "[dbo].[Table_2]",
        Clear(
            collection3)
    )
)

 

1.jpg

Best Regards,

Bof

 

 

View solution in original post

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (1,636)