cancel
Showing results for 
Search instead for 
Did you mean: 

Collection indexer: Collection[index]

I think it would be very usefull to be able to access a Table record by its index. For example if I create Images collection when screen becomes visible:

 

OnVisible: UpdateContext({Images: [bg1, bg2, bg3, bg4]})

and I have an image control on this screen it would be nice to be able to set Image property for this control like this:

 

 

Images[1]

accessing the second record in a collection (assuming 0 is the first one).

Because now to achieve something similar I have to modify the collection, add some kind of Index or Name property and Filter() or LookUp() this collection by one of this properties but not the actual index.

 

Status: Declined

The concept of indexed values in an array or collection is a very complex topic in light of the audience of citizen developers building apps in PowerApps (as far as we see today). However, the good news is that your scenario will become much easier to accomplish as we continue to enhance FX functions and configuration options...ideally heading towards something easier to intuitively use for everyone.

 

I also would like to invite you to my upcoming formula webinar where I will be demonstrating some really cool ways to save time and 'do more with less' in functions. Here is the invite:

 

https://powerapps.microsoft.com/en-us/blog/free-getting-started-webinars-on-galleries-and-formulas-2...

 

Thank you for your patience as we continue to evolve the user experience with all audiences in mind.

 

Audrie

Comments
Power Automate Staff
Status changed to: Declined

The concept of indexed values in an array or collection is a very complex topic in light of the audience of citizen developers building apps in PowerApps (as far as we see today). However, the good news is that your scenario will become much easier to accomplish as we continue to enhance FX functions and configuration options...ideally heading towards something easier to intuitively use for everyone.

 

I also would like to invite you to my upcoming formula webinar where I will be demonstrating some really cool ways to save time and 'do more with less' in functions. Here is the invite:

 

https://powerapps.microsoft.com/en-us/blog/free-getting-started-webinars-on-galleries-and-formulas-2...

 

Thank you for your patience as we continue to evolve the user experience with all audiences in mind.

 

Audrie

PowerApps Staff

Notice that you can access an item by index today - you can use the Last and FirstN functions. In your scenario, to access the second element in the Images table, you can use the expression below:

Last(FirstN(Images, 2))
Level: Powered On

Not to argue but if this is Excel like and Excel let's us use Arrays what would the reason for not providing similar functionality here?

Level: Powered On

I have done By this Logic

Select(Parent);RemoveIf(ProductList, Index = Gallery2.Selected.Index);

 

Clear(collection2);

ForAll(ProductList,
Collect(collection2,
{
Index: CountRows(collection2)+1,
Comments: Comments,
SalesPrice: SalesPrice,
Discount: Discount,
Quantity: Quantity,
Height: Height,
Width: Width,
Color: Color,
ProfileSet: ProfileSet,
Product: Product,
Group: Group
}
)
);
Clear(ProductList);
ForAll(collection2,
Collect(ProductList,
{
Index: Index,
Comments: Comments,
SalesPrice: SalesPrice,
Discount: Discount,
Quantity: Quantity,
Height: Height,
Width: Width,
Color: Color,
ProfileSet: ProfileSet,
Product: Product,
Group: Group
}
)
);
Set(ValueToIncrement, CountRows(ProductList));

wrote: -Jayprakash Birla