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 / How do I collect all t...
Power Apps
Unanswered

How do I collect all the data from a table?

(0) ShareShare
ReportReport
Posted on by 152

Hi, 
I have a filtered table in my app: 

Alienvolm_0-1623086369557.png

Every time I click on the "Request report" button I would like to create a collection of the resulting table. I thought I could just plug the entire Table as an argument but that doesn't work... 😛 

 

Alienvolm_1-1623086627166.png

 

Alienvolm_2-1623086688827.png

 

Any help with the syntax would be greatly appreciated! 

 

Thanks in advance! 

Categories:
I have the same question (0)
  • TheRobRush Profile Picture
    11,128 Moderator on at

    As far as I am aware, unless it has changed, you cannot collect all the records from a data table within powerapps.

     

    You could however run a collect on the source data using same filter parameters being visualized in your datatable, and this would have same affect.

  • Alienvolm Profile Picture
    152 on at

    Ouch... could I export the table to Excel or CSV without saving it in a collection then? I know I need a Flow to do that, but I only found instructions to do that from a collection...

  • TheRobRush Profile Picture
    11,128 Moderator on at

    Possibly, but you'd need to hop over to the power automate forums for that. I am not sure of the json limitations so can't tell you yes or no with certainty. I can say however it would be easier though to just stay in powerapps and use my suggestion of having the button instead of collecting the datatable, collect the datatables source using an identical filter as the one in place on your datatable.

  • Alienvolm Profile Picture
    152 on at

    Makes sense... I just tried and it seems to work, but now I have all the fields from the datasource and I believe I have to drop some of those fields to only save what I need in the collection... 

     

    Thanks for the hint! 

  • TheRobRush Profile Picture
    11,128 Moderator on at

    Here's a helpful post on how to do that

     

    Remove Columns From A Collection - Matthew Devaney

  • Alienvolm Profile Picture
    152 on at

    So... 

     

    This is the code for my button so far...

     

    Alienvolm_0-1623090411557.png

    However, when I run the report and then I check the collection, it doesn't seem to have dropped any of the extra columns and I don't see the values in the rows other than the in the first field... 

     

    Alienvolm_1-1623090608050.png

     

    What am I doing wrong? I tried to incorporate the DropColumn in the ClearCollect but it gives me errors... 

     

    I also tried to assign the entire Search statement to a variable to clean up the code a bit but I get errors again... 😐 

  • TheRobRush Profile Picture
    11,128 Moderator on at

    So just tested this on my side, filtering a roster in sharepoint and dropping the columns into a collection. The following code did it as intended, leaving only 3 columns of info in a new collection in powerapps.

     

    ClearCollect(
     LeadTest2,
     DropColumns(
     Filter(
     LDROSTER,
     Or(
     Title = "A,Man",
     Title = "Bonilla,E"
     )
     ),
     "{VersionNumber}",
     "{FilenameWithExtension}",
     "{FullPath}",
     "{HasAttachments}",
     "{Identifier}",
     "{IsFolder}",
     "{Link}",
     "{ModerationComment}",
     "{ModerationStatus}",
     "{Name}",
     "{Path}",
     "{Thumbnail}",
     "{TriggerWindowEndToken}",
     "{TriggerWindowStartToken}",
     "Author",
     "ComplianceAssetId",
     "Created",
     "Editor",
     "EMAIL",
     "Modified",
     "oskw",
     "ROLE"
     )
    )
  • Alienvolm Profile Picture
    152 on at

    So... I tried to follow your code as a sample. 

     

    This is what I had before: 

     

    //Creates a collection from the table to be exported
    
    ClearCollect(
     ExportTable, 
     Search(
     AddColumns(
     Filter('[dbo].[JourneyUser]', 
     (BatchNameDropdown.Selected.Result = "All" || BatchName = BatchNameDropdown.Selected.Result)
     ),
     "E911", LookUp(UserResponse, JourneyUserID=id && QuestionID=34, Response)
     ),
     TextInput2.Text, "BatchName"
    
     )
    );
    
    //Creates variable that eliminates extra columns from the table
    Set(varDroppedColumns,
     DropColumns(
     ExportTable, 
     "CurrentPhase", "CreatedDatetime", "CurrentPhaseStartDate", "id", "JourneyActualStartDate", "JourneyPlannedStartDate", "MigrationCompletedDateTime", "Phase1EndDate", "Phase1PlannedStartDate", "Phase2PEndDate", "Phase2PlannedStartDate", "Phase3EndDate", "Phase3PlannedStartDate", "UpdatedDatetime", "CreatedBy", "MigrationComplete", "MigrationCompletedByAdmin", "MigrationCompleteEmailSent", "TenantID", "UpdatedBy", "JourneyPathID", "isInActive"
     )
    ); 
    
    //Sets variable that formats the JSON File
    Set(varFormattedJSON, 
     JSON(varDroppedColumns, JSONFormat.IndentFour)
    );
    
    //Executes the flow
    
    E911SendMail.Run(varFormattedJSON);
    
    //Navigates to Sent screen
    
    Navigate(SuccessScreen, ScreenTransition.Fade)

     

    This is what I previewed (which is the right fields, except for the fact that they're empty except for the first column): 

    Alienvolm_0-1623098190814.png

     

    Then, I modified the code as follows: 

     

    /Creates a collection from the table to be exported
    
    ClearCollect(
     ExportTable, 
     DropColumns(
     Search(
     AddColumns(
     Filter('[dbo].[JourneyUser]', 
     (BatchNameDropdown.Selected.Result = "All" || BatchName = BatchNameDropdown.Selected.Result)
     ),
     "E911", LookUp(UserResponse, JourneyUserID=id && QuestionID=34, Response)
     ),
     TextInput2.Text, "BatchName"
     ),
     "CurrentPhase", 
     "CreatedDatetime", 
     "CurrentPhaseStartDate", 
     "id", 
     "JourneyActualStartDate", 
     "MigrationCompletedDateTime", 
     "Phase1EndDate", 
     "Phase1PlannedStartDate", 
     "Phase2PEndDate", 
     "Phase2PlannedStartDate", 
     "Phase3EndDate", 
     "Phase3PlannedStartDate", 
     "UpdatedDatetime", 
     "CreatedBy", 
     "MigrationComplete", 
     "MigrationCompletedByAdmin", 
     "MigrationCompleteEmailSent", 
     "TenantID", 
     "UpdatedBy", 
     "JourneyPathID", 
     "isInActive"
     )
    );
    
    //Creates variable that eliminates extra columns from the table
    Set(varDroppedColumns,
     ExportTable
    ); 
    
    //Sets variable that formats the JSON File
    Set(varFormattedJSON, 
     JSON(varDroppedColumns, JSONFormat.IndentFour)
    );
    
    //Executes the flow
    E911SendMail.Run(varFormattedJSON);
    
    //Navigates to Sent screen
    Navigate(SuccessScreen, ScreenTransition.Fade)

     

    And now it doesn't find any data at all... 

     

    Alienvolm_1-1623098467758.png

     

    In both cases, the flow seems to work well: when I execute the code, I do receive an email with an Excel file attached (which is the intended purpose of the app), but I only see two fields... 

     

    Alienvolm_2-1623098589980.png

    Any suggestions on how to fix this?

  • TheRobRush Profile Picture
    11,128 Moderator on at

    Hard to tell without having your setup mirrored on my side. But Since my test is working perfectly, I would think the changes you made are responsible for the different results (changing the filter to a search, etc) Is that dropdown what they are selecting a filter value off of? Or are they allowed to type a custom filter in the search box as well? Either way you don't have to do a search, you can still run this as a filter with something like the following, which will filter all results back that contain the string specified (ie what they typed in, or dropdown value)

     

    ClearCollect(
     LeadTest2,
     DropColumns(
     Filter(
     LDROSTER,
     "Man" in Title
     ),
     "{VersionNumber}",
     "{FilenameWithExtension}",
     "{FullPath}",
     "{HasAttachments}",
     "{Identifier}",
     "{IsFolder}",
     "{Link}",
     "{ModerationComment}",
     "{ModerationStatus}",
     "{Name}",
     "{Path}",
     "{Thumbnail}",
     "{TriggerWindowEndToken}",
     "{TriggerWindowStartToken}",
     "Author",
     "ComplianceAssetId",
     "Created",
     "Editor",
     "EMAIL",
     "Modified",
     "oskw",
     "ROLE"
     )
    )
  • Alienvolm Profile Picture
    152 on at

    @RandyHayes,  any suggestions? 

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

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 272

Last 30 days Overall leaderboard