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 / Creating a Nested Tabl...
Power Apps
Unanswered

Creating a Nested Tables Context

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I'm creating a lookup context table of tables that will allow me to set choice lists for forms on the fly.  The idea is to create an outcome like this:

 

{

  TableName: Table1

  TableValue: {

    Record: {

      DisplayColumn: Display1,

      ValueColumn: Value1

    },

    Record: {

      DisplayColumn: Display2,

      ValueColumn: Value2

    }

  },

  TableName: Table2...... Etc.

 

Here's the code I have:

 

 

ClearCollect(
 colRequestChoiceContext,
 ForAll(
 Filter(
 colRequestSummaryMerged,
 lg_columntype = 'Column types'.Choice
 ),
 {
 TableName: RequestAlias & "_" & ThisRecord.lg_datafield,
 TableValue: Switch(
 ThisRecord.lg_lookupmethod,
 'Choice Lookup Methods'.'Choice List',
 ForAll(
 Split(
 lg_choicelist,
 ","
 ),
 {
 ColumnName: First(
 Split(
 Value,
 ":"
 )
 ).Value,
 ColumnValue: Last(
 Split (
 Value,
 ":"
 )
 ).Value
 }
 )
 )
 }
 )
);

 

 

I have several methods of looking up the option values, but I'm starting out with the simple explicit collection which I parse with a Split function.  

 

I do get a table of TableName/TableValue with the value being a table.  Trouble is each value table is itself a list of tables, which is not what I wanted.  I'd like to be able to assign a dropdown items property with something like:

 

        Filter(colRequestChoiceContext,TableName = RequestAlias & "_" & ThisItem.lg_datafield).TableValue
 
Instead, the records I want are in 
        
        First(Filter(colRequestChoiceContext,TableName = RequestAlias & "_" & ThisItem.lg_datafield).TableValue).TableValue
 
I suppose it's not the end of the world, but when I finish the Switch statement with other methods to gather this data, I'll need the formats to match.  Any idea how I can get rid of this extra layer?
 
Thanks much!
Categories:
I have the same question (0)
  • gcmfaizan Profile Picture
    1,022 on at

    Hi @lionelgo ,

     

    It seems like you're trying to create a lookup context table with dynamic choice lists for forms. Your code appears to be mostly correct, but it seems there's a bit of confusion with the structure of nested tables.

    Here's how you can achieve this structure:

     

     

    ClearCollect(
     colRequestChoiceContext,
     ForAll(
     Filter(
     colRequestSummaryMerged,
     lg_columntype = 'Column types'.Choice
     ),
     {
     TableName: RequestAlias & "_" & ThisRecord.lg_datafield,
     TableValue: If(
     ThisRecord.lg_lookupmethod = 'Choice Lookup Methods'.'Choice List',
     Split(lg_choicelist, ","),
     [] // You can add other methods here
     ),
     // Optional: You can parse TableValue into individual records if needed
     ParsedTableValue: Table(
     { DisplayColumn: First(Split(Value, ":")).Value, ValueColumn: Last(Split(Value, ":")).Value },
     TableValue
     )
     }
     )
    );

     

     

    This code makes sure that the TableValue field contains an array of values directly. When using the dropdown items property, you can do it like this:

     

    Filter(
     colRequestChoiceContext,
     TableName = RequestAlias & "_" & ThisItem.lg_datafield
    ).ParsedTableValue

     

     

     

    If this is the answer for your question, please mark the post as Solved.
    If this answer helps you in any way, please give it a like.

  • lionelgo Profile Picture
    Microsoft Employee on at

    This is along the right lines, but you're only returning one record.  I really do want a Table for TableValue, but I don't want the extra layer of TableValue.  Any ideas?

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

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard