cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ericonline
Community Champion
Community Champion

Toggle Mindboggle

Hello,

I'm getting loopy on this one. Usually a good time to reach out for help (or to just practice describing complexity in text 🙂 )

Scenario:

  • Gallery where each item has a Toggle Control ("little toggles")
    • Data Source feeding the Gallery has a toggle "value" for each Item
    • Default Property of "little toggles" set to the Data Source toggle "value" OR the MasterToggle ("BigToggle") value depending on:
      • The state of the Data Source toggle value AND
      • The state of the BigToggle
    • Visual Aid:
    • image.png

Problem:

  • OnChange of "little toggles":
    • IF toggle value does not equal Data Source value,  Collect ID and Status from ThisItem
    • IF value does equal Data Source, do not Collect anything, AND, if the ID and Status were already collected for ThisItem, Remove them from the Collection.
  • Here is the mess of code i'm wrapped around:
    • If(
          Or(
              ThisItem.NestedTable1.Status <> 
                  If(
                      little_toggle.Value = false,"N",  // The Data Source toggle values come in as "N" or "Y".
                      little_toggle.Value = true,"Y"
                  ),
              IsBlank(
                  Filter(
                      First(
                          colStatus.NestedTable
                      ).NestedTable2, 
                      NestedObject.ID = ThisItem.NestedObject.ID
                  )
              )
          ),
          Collect(colStatus,
              Table(
                  {
                      all: kinds,
                      ofCrazy:
                      Table(
                          {
                              things: ThisItem.what,
                              things2: ThisItem.seriously,
                              NestedTable2: {
                                  ID: ThisItem.NestedObject.ID,
                              },
                              NestedTable1:{
                                  Status: 
                                  If(
                                     little_toggle.Value = false,"N",
                                      little_toggle.Value = true,"Y"
                                  )
                              }
                          }
                      )
                  }
              )
          ),
          Remove(
              First(colStatus.NestedTable2
                      ).NestedTable2,
              LookUp(                                   //Also tried Filter here, no go
                  First(colStatus.NestedTable2
                      ).NestedTable2, 
                      NestedObject.ID= ThisItem.NestedObject.ID
                  )
          )
      )

Looking for: 

  • Another set of eyes!
  • Someone to shed some pointers, who's had a similar "BigToggle/littletoggle" scenarios where you Collect one way, then Remove the other. 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @ericonline ,

Could you please share a bit more about your issue?

Do you mean that the Remove() formula part within the formula that you provided do not work?

 

Based on the formula that you provided, I think there is something wrong with it. I have made a test on my side, please consider take a try to modify your formula as below:

If(
    Or(
        ThisItem.NestedTable1.Status <> 
            If(
                little_toggle.Value = false,"N",  // The Data Source toggle values come in as "N" or "Y".
                little_toggle.Value = true,"Y"
            ),
        IsBlank(
            Filter(
                First(
                    colStatus.NestedTable
                ).NestedTable2, 
                NestedObject.ID = ThisItem.NestedObject.ID
            )
        )
    ),
    Collect(colStatus,
        Table(
            {
                all: kinds,
                ofCrazy:
                Table(
                    {
                        things: ThisItem.what,
                        things2: ThisItem.seriously,
                        NestedTable2: {
                            ID: ThisItem.NestedObject.ID,
                        },
                        NestedTable1:{
                            Status: 
                            If(
                               little_toggle.Value = false,"N",
                                little_toggle.Value = true,"Y"
                            )
                        }
                    }
                )
            }
        )
    ),
    Remove(    /* <-- Modify your formula here */
           colStatus,   /* <-- Type your Collection data source here, rather than nested table */
           LookUp(colStatus, First(ofCarry.NestedTable2).NestedTable2.ID = ThisItem.NestedObject.ID)
    )
)

Please take a try with above solution, then check if the issue is solved.

More details about the Remove function, please check the following article:

Remove function

 

Best regards,

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-xida-msft
Community Support
Community Support

Hi @ericonline ,

Could you please share a bit more about your issue?

Do you mean that the Remove() formula part within the formula that you provided do not work?

 

Based on the formula that you provided, I think there is something wrong with it. I have made a test on my side, please consider take a try to modify your formula as below:

If(
    Or(
        ThisItem.NestedTable1.Status <> 
            If(
                little_toggle.Value = false,"N",  // The Data Source toggle values come in as "N" or "Y".
                little_toggle.Value = true,"Y"
            ),
        IsBlank(
            Filter(
                First(
                    colStatus.NestedTable
                ).NestedTable2, 
                NestedObject.ID = ThisItem.NestedObject.ID
            )
        )
    ),
    Collect(colStatus,
        Table(
            {
                all: kinds,
                ofCrazy:
                Table(
                    {
                        things: ThisItem.what,
                        things2: ThisItem.seriously,
                        NestedTable2: {
                            ID: ThisItem.NestedObject.ID,
                        },
                        NestedTable1:{
                            Status: 
                            If(
                               little_toggle.Value = false,"N",
                                little_toggle.Value = true,"Y"
                            )
                        }
                    }
                )
            }
        )
    ),
    Remove(    /* <-- Modify your formula here */
           colStatus,   /* <-- Type your Collection data source here, rather than nested table */
           LookUp(colStatus, First(ofCarry.NestedTable2).NestedTable2.ID = ThisItem.NestedObject.ID)
    )
)

Please take a try with above solution, then check if the issue is solved.

More details about the Remove function, please check the following article:

Remove function

 

Best regards,

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Wow Kris @v-xida-msft !

You are far and away one of the most diligent members of this community. Thank you for always digging into the code and posting thoughful solutions. You have helped me develop very complex applications and I'm very grateful.

#PowerHomies!!

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Carousel April Dunnam Updated 768x460.jpg

Urdu Hindi D365 Bootcamp

Dont miss our very own April Dunnam’s The Developer Guide to the Galaxy! Find out what the Power Platform has to offer for the traditional developer.

Top Solution Authors
Top Kudoed Authors
Users online (2,013)