jeudi 9 mai 2019

How can I handle circular reference error in powerapps when trying to filter selections of two comboboxes depending on each other?

I am using PowerApps to create a small app which contains two comboboxes, which filter information that are being displayed on a data table and come from an excel sheet called Table. More specifically, my first combobox is called ColorCombo and displays distinct values, which come from the column Color of the sheet Table and the second combobox is called SizeCombo and displays distinct values that are contained on the column Size of the Table

My goal is to filter the information of the one combobox depending on the selection of the other combobox.

For instance, I have the colors : [Red, Blue,Green] listed on the ColorCombo and the sizes: [32,34,36] listed on the SizeCombo. If the red color is only available on size 32 then when I select the red option on the colorcombo I want to only see the number 32 on the SizeCombo and if the size 32 is available on green and blue color then when I select it on the SizeCombo I want to only see the options green and blue on the ColorCombo. The code I have so far is:

Sort(Distinct(Filter(Table, If(CountRows(ColorCombo.SelectedItems) = 0,true, 
Size in SizeCombo.SelectedItems)),Color),Result,Ascending)

which works ok for the colorcombo. When I add the same statement for the SizeCombo as well though, I get an circular reference error. This is the statement I input:

Sort(Distinct(Filter(Table, If(CountRows(SizeCombo.SelectedItems) = 0,true, 
Color in ColorCombo.SelectedItems)),Size),Result,Ascending)

I understand that this is happening because the selection of the comboboxes are depending on each other recursively, so this happens to prevent an infinite loop, but how could I solve this? I appreciate any help you can provide, since I have been trying to find a solution to it since a long time.




Aucun commentaire:

Enregistrer un commentaire