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 / Access a Collection pr...
Power Apps
Suggested Answer

Access a Collection property Dynamically with Variable

(0) ShareShare
ReportReport
Posted on by

 

Hi Power Platform Community, do you know if it is possible to access a collection property dynamically in power apps?

 

rico98_0-1649748640859.jpeg

 

I have the following myMonth property that I want to use to dynamically access the value of a property.

 

and accessing it simply gives me an error like this:

rico98_1-1649748640859.jpeg

 

I am basically trying to reproduce a transposed table. 

Happy for any workaround to being introduced. Thank you.

 

Regards,

Rico.

 

Categories:
I have the same question (0)
  • C-Papa Profile Picture
    1,836 on at

    hi, you need to use the Concat() function to do this. something like Concat(Table1,Text(myMonth,"dd-mm-yyyy"),", ")

  • Community Power Platform Member Profile Picture
    on at

    Thanks for your suggestion. I tried something like you suggested, but still not getting the right value.

     

    Basically, I want to get this value:

    rico98_0-1649753874427.png

     

    But I am getting the following value instead:

    rico98_1-1649753923791.png

    Is there anything that I did wrong.

    I tried without the Text function too.

     

     

  • C-Papa Profile Picture
    1,836 on at

    You can't pass the column name dynamically into the function. you would need to use the If or Switch function to change the formula for all of the months, but this isn't really scalable. I would have probably done it a bit differently by having a "Date" column rather than a new column for every year. This would allow you to filter the database based on a date and return the values you need, which would all be in one column.  Concat() would then work as expected. 

  • Community Power Platform Member Profile Picture
    on at

    Thanks for your suggestion.

     

    But this is the business requirements, they want to be able to add a new month as a column.

     

    Regards,

    Rico.

  • C-Papa Profile Picture
    1,836 on at

    In that case i think you are unlikely to get an app that works for them through PowerApps. By doing it the way i suggested you will still get the correct data, it will also allow you to filter much better and your table will not be so large. you have to remember that if your table is growing in columns year on year you will get to a point where its not useable. i can't see this being a scalable approach. 

     

    if you google "powerapps select column dynamically" you will see lots of threads where this has previously been talked about. Good luck

  • Community Power Platform Member Profile Picture
    on at

    Thank you so much for your detailed suggestion and explanation.

    I will take this into consideration. Have a great day.

  • WarrenBelz Profile Picture
    153,084 Most Valuable Professional on at

    @Anonymous ,

    If you want confirmation on @C-Papa 's explanation of dynamic referral of Power Apps elements such as Field, List or Control names, then it is absolutely correct - you simply cannot do it.

  • Suggested answer
    BostonSailor Profile Picture
    154 on at
    You can't in Power Apps, but you can in Power Automate. I face this often when a custom connector returns a JSON dictionary rather than a JSON array.
     
    SampleArray:
    [
      {"Key": "ABCD", "Value": 1},
      {"Key": "EFGH", "Value": 2}
    ]
     
    SampleDictionary:
    {
      "ABCD":
        {"Value": 1},
      "EFGH":
        {"Value": 2}
    }
     
    To find a value in the array, I might:
    LookUp(SampleArray, Key="ABCD").Value
     
    If the key I want is a constant, then I could do this in the dictionary:
    SampleDictionary.ABCD.Value
     
    But let's say the key I want is a string variable called MyKey. I might want to say:
    SampleDictionary.MyKey.Value   // That surely won't work
    LookUp(SampleDictionary, Key=MyKey).Value  // That won't work either, as the dictionary is not a table
     
    In desperation, I end up writing a short Power Automate flow, passing the dictionary (or whatever) into the flow as a JSON string.
    After whatever massaging is needed to create Compose actions with my dictionary and my key, I can then use an expression like this:
    Outputs('SampleDictionary')?[Outputs('MyKey')]
    and get value(s) from that as...
    Outputs('SampleDictionary')?[Outputs('MyKey')]?['Value']
     
    If you haven't already, it may require a new learning curve to get familiar with Power Automate (whose language bears no resemblance to Power Fx). But as far as I know it's the only way to do it. 
     
     
     

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 739 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 268

Last 30 days Overall leaderboard