Filter many to many relationship in Canvas app using Power fx

438 views Asked by At

I have two tables 'Vehicle' and 'Vehicle Features' which has N:N relationship. I have a combobox to select multiple 'Vehicle Features'Combo box to select multiple Vehicle Features. I want to filter the list of 'Vehicles' and display it in gallery('availableVechilesGallery') when the user click the Search button which have the selected Vehicle Features from the combobox('comFeatures').

Error is Specified Column is Not Accessible in this Context

//didn't work
    ForAll(Vehicles, Collect(filteredFeatVehicles,ThisRecord.'Vehicle Features' in comFeatures.SelectedItems));


    //didn't work
    ClearCollect(filteredVech, Filter(Vehicles, 'Vehicle Features'.Name in comFeatures.SelectedItems.Name));
1

There are 1 answers

0
Prashant Pokhrel On
ClearCollect(
        colFilteredVehicles,        
        Filter(
            Vehicles As Vec,
            !(false in ForAll(
                comFeatures.SelectedItems, Name in Vec.'Vehicle Features'.Name
            ))
        )
    );

There is an option in settings under Experimental tab "Record scope one-to-many and many-to-many relationships" which needs to be toggled on for above formula to work. Looping through the N:N data requires this settings turned on.

Record scope one-to-many and many-to-many relationships image