cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Super User
Super User

Re: Set Toggle Control to true in form if all items in Gallery have same value

Just to share some of the insights I've had on this (again, thanks @RandyHayes):

The AddColumns() Function I was able to get working is as follows:

  • Instantiated: At the Gallery-Items-Property-level, not at ClearCollect
AddColumns(
    First(
        First(
            colCustomConnectorResponse.level1
        ).level1.level2
    ).level2,
    "myNewColumn",
    If(
        level3.level4 = "Y", //<--This is a SUBSTANTIAL piece. Notice how the dot notation just picks up at .level3, where the above "digging" left off (at .level2)!!
        1,0
) )
  • Now, just like Randy said, I have something to pivot off of:
  • Sum(Gallery.AllItems, myNewColumn)

So creative! Hope this helps others too!

Super User
Super User

Re: Set Toggle Control to true in form if all items in Gallery have same value

Another interesting finding here...

  • A circular reference is created if trying to reference Sum(gallery.AllItems, myNewColumn) from within the Gallery.
    • Not sure why exactly this is since the AddColumns is (more or less) a calculated column.
    • I see this column as separate from the Data Source itself and should be able to be referenced/manipulated at will. (but not the case).
  • Example:
    • "Master" toggle outside the gallery
    • Default value set to: 
      If(
          Sum(gallery.AllItems, myNewColumn) 
          = 
          CountRows(colData), 
          true, 
          false
      )
    • Error"creates a circular reference"
    • Even placing Sum(gallery.AllItems, myNewColumn) into a Label Control outside the Gallery cannot be referenced by a Label Control inside the Gallery...

hm.

Super User
Super User

Re: Set Toggle Control to true in form if all items in Gallery have same value

Another interesting finding here...

  • A circular reference is created if trying to reference Sum(gallery.AllItems, myNewColumn) from within the Gallery.
    • Not sure why exactly this is since the AddColumns is (more or less) a calculated column.
    • I see this column as separate from the Data Source itself and should be able to be referenced/manipulated at will. (but not the case).
  • Example:
    • "Master" toggle outside the gallery
    • Default value set to: 
      If(
          Sum(gallery.AllItems, myNewColumn) 
          = 
          CountRows(colData), 
          true, 
          false
      )
    • Error"creates a circular reference"
    • Even placing Sum(gallery.AllItems, myNewColumn) into a Label1 Control outside the Gallery cannot be referenced by a Label2 Control inside the Gallery using Label1.Text.
      • **EDIT**: HA! but using a variable works...
        • OnVisible:  Set(varMyCount, Sum(gallery.AllItems, myNewColumn))
        • Label1 outside Gallery: varMyCount
        • Label2 inside Gallery: Label1.Text

hm.

Super User
Super User

Re: Set Toggle Control to true in form if all items in Gallery have same value

@ericonline 

Yes, this is the case...you cannot have circular references that will directly or indirectly impact each other.  In your case, you are impacting outside of the gallery.

Even though AddColumns is a calculated column, it is the fact that AddColumns returns a Table.  THAT is the table that is the source of your items. So, whatever is in the AddColumns as a datasource, no longer is.  It's the results.

 

When inside the gallery, you do not have access to the current gallery AllItems property. Can't force it...you will get an error.

When inside the gallery, you cannot reference a control outside of the gallery that references the AllItems property of that gallery - you will get a circular reference error.

 

If you want to be able to have the sum of the values available from within the gallery, you will need to collect the items first, then add the sum column to your items of the Gallery...

So, if you had a list with values (even AddColumn values), you could toss this into a collection - let's call it Ericonline, and then your Gallery could have this - AddColumns(Ericonline, "TotalSum", Sum(Ericonline, columnWithValue))

Now in your gallery, you can reference ThisItem.TotalSum

 

BUT, all this seems complex for what you are trying to do...maybe a thinking moment, but hope something here is helpful.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 48 members 4,623 guests
Please welcome our newest community members: