Search code examples
powerappspowerapps-formula

How do I count the number of times that checkbox is in disabled mode in a gallery?


I need code that reports back to a text label called lblDis where I am getting a count of the number of instances where the checkbox value chkVal's disabled mode is set to disable in the gallery galTick.

I have tried this:

Code in OnVisible of the screen:

ClearCollect(colDisabledCount, Filter(galTick.AllItems, chkVal.DisplayMode = DisplayMode.Disabled)); UpdateContext({disabledCount: CountRows(colDisabledCount)});

but that throws an error that .DisplayMode is not available in this context.

Code in lblDis: "Disabled Count: " & disabledCount

Thank you for any help that you can provide.


Solution

  • I don't think you can count these values this way.

    There are two alternative approaches I could recommend:

    1. In the checkbox OnChange, increment/decrement a global counter variable.
    2. In the checkbox OnChange, update with a new boolean field in your data source.