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 / Output data from Listb...
Power Apps
Unanswered

Output data from Listbox to Excel sheet on OneDrive

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello all! 

 

I'm new to PowerApps and struggling along by myself at work. I'm hoping that this hasn't been answered before. I've tried searching on Google and on these forums, but haven't found an answer quite yet. I am trying to take data from a List Box and export the amount of items selected to an Excel document on my OneDrive. Here's the code that I've been trying to no success:

 

Collect(WellnessTracking.'Preventive Activities', CountRows(preventiveActivities_listBox.SelectedItems))

 

Here's an image of my table

workbook.png

My goal is for a user to select which activities they participated in in a list box in my app and that count be placed in the appropriate cell in my Excel sheet. Thanks for the help!

Categories:
I have the same question (0)
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    So this has been talked about in many varieties - but let me see if I can address yours more.

    My first question would be, where is the data that you are using in your PowerApps coming from?

    The next point, creating Excel from PowerApps...not quite what you would think it would be.  PowerApps is really great with using Excel as a datasource, but that was the intention - A DataSource.  Not as an Excel file builder.  

    Now there are connectors available that will let you do this to some degree, but my thought goes back to my first question - if you have a datasource that is feeding your PowerApp, then why not just tie an Excel file to your datasource as well and use a Pivot Table or other data gathering / analysis features to provide that list you want?

    If it's too complex of data, you could also consider Power BI to help out.

    But again...all goes back to where is your actual data?

  • v-xida-msft Profile Picture
    Microsoft Employee on at

    HI @Anonymous ,

    Could you please share a bit more about your scenario?

    Do you want to patch the amount of items selected in your ListBox control into your Excel table?

     

    Based on the formula that you mentioned, I think there is something wrong with it. The first argument of the Collect() function is required to provide a data source rather than a Column table.

    I have made a test on my side, please modify your formula as below:

    Collect(
    WellnessTracking,
    {'Preventive Activities': CountRows(preventiveActivities_listBox.SelectedItems)}
    )

    In addition, I also think the Patch function could achieve your needs. Please take a try with the following workaround:

    Set the OnSelect property of the "Submit" button to following formula:

    Patch(
      WellnessTracking, /* <-- WellnessTracking represents your Excel table data source */
     Defaults(WellnessTracking),
     {
     'Preventive Activities': CountRows(preventiveActivities_listBox.SelectedItems)
     }
    )

    More details about the Collect function and Patch function, please check the following article:

    Collect function

    Patch function

     

    Best regards,

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @RandyHayes 

     

    Thanks for getting back to me. You may have inadvertantly answered a question of mine - can you build an Excel sheet from PowerApps. My intended goal is to have a user facing interface to track events that would then fill out the Excel sheet. So I'm attempting to use PowerApps as an Excel file builder. I take it from the tone of your message that this isn't possible? The goal of the app was to have multiple users enter data on seperate lines on a central Excel sheet. Is there a better data source for this? Or is this not an intended application of PowerApps? Thanks!

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

     

     

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    So, the answer still is Yes - you can build Excel sheets from PowerApps.  The road to that has some potholes in it.

    Slam dunk - No.  Some work and understanding - Yes.  

    Better sources for your intended solution - Yes.  I would consider SharePoint as a data source for this.  It's just as easy to set up with a List (just like Excel).  Works well as a DataSource in this case.  And, as I mentioned in previous postings, You can always tie Excel to your SharePoint as a DataSource should you want to have "pretty" formats and sheets.

    PLUS...you totally avoid the Sharing issue of people with the file open while trying to update and edit it from PowerApps.  SharePoint is built to share!

     

    If your solution needs to actually create an Excel file, then you need to look to the other Connectors such as the Plumsail Documents or the Excel Online connector.  Both of these will "generate" an Excel file (both has cost to them), but they are not intended to then be consumed as a DataSource in PowerApps.

     

    I hope that helps provide more detail - if not, feel free to post back.

     

     

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

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 337 Most Valuable Professional

#2
11manish Profile Picture

11manish 173

#3
Valantis Profile Picture

Valantis 86

Last 30 days Overall leaderboard