Recently I was asked about issues related to ambiguity in Power Apps code. In this post I will look at how to avoid any ambiguity issues in Power Apps.
First of all what is ambiguity? According to the dictionary, it is all about things not being clear as multiple explanations can be given to the same thing.
Ok, that’s all great! But what does that have to do with Power Apps.
I’m going to start by creating two collections. Using the following code I’m going to create a collection called colFruit:
ClearCollect(
colFruit,
{
Type: "Apple",
Colour: Green
},
{
Type: "Apple",
Colour: Red
},
{
Type: "Plum",
Colour: Red
},
{
Type: "Plum",
Colour: Yellow
},
{
Type: "Banana",
Colour: Yellow
}
);
And for my second collection I’m going to created a collection of cars
ClearCollect(
colCars,
{
Type: "Nissan",
Colour: Red
},
{
Type: "Volkswagen",
Colour: Yellow
},
{
Type: "Ford",
Colour: Green
}
);
Now using the colour of the cars, I want to suggest the fruits that share the same colour as the car.
A first attempt might give you code like this:
But the above code of course will not work.
Colour is the same as Colour as I’m not specifying where the Colours are coming from ( either the colFruit or colCars collections ) the expression doesn’t make much sense.
We can now let the expression make sense by changing the code a bit.
ClearCollect(
colSuggestFruitByColour,
ForAll (
colCars,
First(Filter(
colFruit,
Colour = colCars[@Colour]
))
)
);
Using the above code, I can specify, the colCars collection used in the ForAll using the following syntax
Collection[@Property]
Using the above construction we can specify which of the datasources we want to use within the nested lines of code.
Continue Reading Pieter Veenstra’s Article on their blog
Ambiguity in Power Apps
Recently I was asked about issues related to ambiguity in Power Apps code. In this post I will look at how to avoid any ambiguity issues in Power Apps.
Blog Syndicated with Pieter Veenstra’s Permission