cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
bennnnnn
Regular Visitor

Weird bug, for certain filters I have to click apply twice to get the results

Hi there, I have a weird bug where I have to click apply twice to make the results appear in the gallery.

The filter code is this:

 

    UpdateContext(
        {
            filteredSKUs: Filter(
                SKUs,
                If(
                    btnGutConversion.Value = true,
                    'Demand Family'.'Gut Conversion' = 'Gut Conversion (Demand Families)'.Yes,
                    'Demand Family'.'Gut Conversion' = 'Gut Conversion (Demand Families)'.No
                ),
                Text('Demand Family'.Category) = Text(drpCategory.Selected.Result)
            )
        }
    );

 
Any idea what could be causing this?

4 REPLIES 4
WarrenBelz
Super User
Super User

Hi @bennnnnn ,

If this is the Items of a gallery, why the Variable?

Filter(
   SKUs,
   If(
      btnGutConversion.Value = true,
     'Demand Family'.'Gut Conversion' = 'Gut Conversion (Demand Families)'.Yes,
     'Demand Family'.'Gut Conversion' = 'Gut Conversion (Demand Families)'.No
   ) &&
   Text('Demand Family'.Category) = Text(drpCategory.Selected.Result)
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

@WarrenBelz It is a variable because the gallery can be updated by a couple of different buttons on the screen. This is the full code for one the apply button with the issue:

 

 

If(
    lblSelectedDemandFamily.Text = "-" And drpCategory.Selected.Result = "-",
    UpdateContext({_popupDF: false});
    Set(
        _showSpinner,
        true
    );
    UpdateContext(
        {
            filteredSKUs: Filter(
                SKUs,
                If(
                    btnGutConversion.Value = true,
                    'Demand Family'.'Gut Conversion' = 'Gut Conversion (Demand Families)'.Yes,
                    'Demand Family'.'Gut Conversion' = 'Gut Conversion (Demand Families)'.No
                )
            )
        }
    );
    Set(
        _showSpinner,
        false
    ),
    lblSelectedDemandFamily.Text <> "-" And drpCategory.Selected.Result <> "-",
    UpdateContext({_popupDF: false});
    Set(
        _showSpinner,
        true
    );
    UpdateContext(
        {
            filteredSKUs: Filter(
                SKUs,
                'Demand Family'.'Family Name' = drpDemandFamily.Selected.Result,
                Text('Demand Family'.Category) = Text(drpCategory.Selected.Result),
                If(
                    btnGutConversion.Value = true,
                    'Demand Family'.'Gut Conversion' = 'Gut Conversion (Demand Families)'.Yes,
                    'Demand Family'.'Gut Conversion' = 'Gut Conversion (Demand Families)'.No
                )
            )
        }
    );
    Set(
        _showSpinner,
        false
    ),
    lblSelectedDemandFamily.Text = "-" And drpCategory.Selected.Result <> "-",
    UpdateContext({_popupDF: false});
    Set(
        _showSpinner,
        true
    );
    UpdateContext(
        {
            filteredSKUs: Filter(
                SKUs,
                If(
                    btnGutConversion.Value = true,
                    'Demand Family'.'Gut Conversion' = 'Gut Conversion (Demand Families)'.Yes,
                    'Demand Family'.'Gut Conversion' = 'Gut Conversion (Demand Families)'.No
                ),
                Text('Demand Family'.Category) = Text(drpCategory.Selected.Result)
            )
        }
    );
    Set(
        _showSpinner,
        false
    )
);
// Update filter
UpdateContext({dmFilter: drpDemandFamily.Selected.Result});
UpdateContext({calibreFilter: "-"});
UpdateContext({colourFilter: "-"});
UpdateContext({oilFilter: "-"});
UpdateContext({halalFilter: "No"});
UpdateContext({manufacturerFilter: "-"});
Reset(drpCalibre);
Reset(drpOilType);
Reset(drpColour);
Reset(btnHalal);
Reset(drpManufacturer);

 

 

@bennnnnn ,

The reason I asked was that a Variable has to be "refreshed" if the value potentially changes, whereas a simple filter on a gallery is "dynamic" and will resolve immediately if any component it is based on changes. Without having to get my head around that lump of code, do you think this may be the issue?

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Hi @bennnnnn ,

Just checking if you got the result you were looking for on this thread. Happy to help further if not.

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Check out the New Ideas Site

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (4,272)