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 / Create a collection fr...
Power Apps
Unanswered

Create a collection from gallery in powerapps

(0) ShareShare
ReportReport
Posted on by 20

Hi.  I'm really new to powerapps so could be doing something stupid!

 

I have a gallery called Projected_Balances_1 which contains text fields pulled from an excel sheet datasource, as well as 'projected balance' column that is a calculated number.

 

michael156_1-1670330468291.png

 

 

I want to add all the items in the gallery to a collection, which I can use with a power automate flow to download a CSV file.  

 

In my app, I have a download button, with the onselect set to:

 

ForAll(Projected_Balances_1.AllItems,
Collect(CSVBalanceData, Projected_Balances_1.AllItems));

Set(ExportToCSVData,Concat(CSVBalanceData, ","&Char(10)));

//Call flow
Set(ResponseFromFlow,'PowerApp->Createfile,RespondtoaPowerApporflow'.Run(Text(varProvision)&"_Report_"&Text(varMonth)&"_"&Text(DateAdd(Now(),TimeZoneOffset(Now())))

,"Cost Code, Starting Budget, Projected Balance, Provision" & Char(10) &ExportToCSVData

));

 

What I can see though, is Projected_Balances_1.AllItems and CSVBalanceData coming back as a table of [control], and then ExportToCSVData is just a text of ',,,,,,,,,,,,,,,,'.

 

michael156_0-1670330391296.png

 

michael156_2-1670330570852.png

 

When the CSV file downloads, it just has the headers in there "Cost Code, Starting Budget, Projected Balance, Provision" without any other content.

 

Can anyone help work out what I'm doing wrong?  Thanks!

Categories:
I have the same question (0)
  • SebS Profile Picture
    4,603 Moderator on at

    You are using ForAll and basically You create a table in a Table

    just use 

     

    Collect(CSVBalanceData, Projected_Balances_1.AllItems)

     

    that will collect all

  • michael156 Profile Picture
    20 on at

    Thanks @SebS.  I've changed the code now 

     

    Collect(CSVBalanceData, Projected_Balances_1.AllItems);

    Set(ExportToCSVData,Concat(CSVBalanceData, ","&Char(10)));

    //Call flow
    Set(ResponseFromFlow,'PowerApp->Createfile,RespondtoaPowerApporflow'.Run(Text(varProvision)&"_Report_"&Text(varMonth)&"_"&Text(DateAdd(Now(),TimeZoneOffset(Now())))

    ,"Cost Code, Starting Budget, Projected Balance, Provision" & Char(10) &ExportToCSVData

    ));

     

    But just getting the same result.  ExportToCSData is just ,,,,,,,,,, with the CSV only containing the headers 🤔

  • michael156 Profile Picture
    20 on at

    Thanks @SebS.  I've changed the code now 

     

    Collect(CSVBalanceData, Projected_Balances_1.AllItems);

    Set(ExportToCSVData,Concat(CSVBalanceData, ","&Char(10)));

    //Call flow
    Set(ResponseFromFlow,'PowerApp->Createfile,RespondtoaPowerApporflow'.Run(Text(varProvision)&"_Report_"&Text(varMonth)&"_"&Text(DateAdd(Now(),TimeZoneOffset(Now())))

    ,"Cost Code, Starting Budget, Projected Balance, Provision" & Char(10) &ExportToCSVData

    ));

     

    But just getting the same result.  ExportToCSData is just ,,,,,,,,,, with the CSV only containing the headers 🤔

  • SebS Profile Picture
    4,603 Moderator on at

    but what do you see in the collection now? is there a data 

  • michael156 Profile Picture
    20 on at

    michael156_0-1670335476026.png

    Its like it collects the cost centre column but everything else just shows [control]

  • SebS Profile Picture
    4,603 Moderator on at

    @michael156 

     

    I'm not sure here it's looks like it's Your gallery or data what populate it create the issue, but I may be wrong.

     

    What is the code You using to populate the gallery?

     

     

  • michael156 Profile Picture
    20 on at

    So it gets a bit complicated here...I have 12 excel tables (one per month) of budget information.  I have a screen in the power app, which has onvisible set to:

    ClearCollect(colFullYearData, April, May, June, July, August, September, October, November, December, January, February, March);

    The gallery then is populated from 

    Distinct(Filter(colFullYearData, Provision = Text(varProvision)), 'Cost Code') with the fields selected for 'Cost Code' (which is the one column that looks to be right in the collection), as well as 'Provision' straight from the data source, but also 'Starting budget' and 'Projected Balance' which are calculations based on the datasource.  

     

    For starting budget, it just checks what month has been selected on the screen (varMonth) and then picks out a value.

    If(varMonth = "April",
    Text(Value(0.00 + LookUp(April, 'Cost Code' = ThisItem.Result && Provision = varProvision, Budget)) ,"£#,###.00"),

     

    The one for Projected Balance remaining is a pretty massive formula but just takes the starting budget and subtracts values for different salary's in the datasource

     

    The data is getting shown correct in the gallery, so I thought it was OK at that point.

     

    michael156_0-1670336267762.png

     

  • michael156 Profile Picture
    20 on at

    After a lot of trial and error, changed the code to:

    ClearCollect(GalleryItems,ShowColumns(AddColumns(Projected_Balances_1.AllItems,"Cost Code",CostCodeLabel_4.Text,"Starting Budget",StartingBudgetLbl_1.Text,"Projected Balance",CurrentMonthProjectedBalance.Text, "Provision",ProvisionLabel_3.Text),"Cost Code","Starting Budget","Projected Balance", "Provision"));

    Set(ExportToCSVData, Concat(GalleryItems, 'Cost Code'&","&'Starting Budget'&","&'Projected Balance'&","&Provision&Char(10)));

     

    Seems to be working now 🙂

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