cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

UpdateIf not working with Switch for multiple collections

Within my app I frequently use a Switch function to point features to different data sources depending on which the user has selected. It is reflected in the Global Variable BusinessUnit. This works well for tables, forms, etc. 

 

 

Switch(
        BusinessUnit,
        "TableA",
        '[dbo].[TableA]',
        "TableB",
        '[dbo].[TableB]',
    )

 

 

 

The following code works as expected:

 

UpdateIf(
    '[dbo].[TableA]',
    UID in DataTable.UID,
    {Date: DataCard1.Update}
)

 

 

 

However, implementing the data source switch, it does nothing:

 

UpdateIf(
    Switch(
        BusinessUnit,
        "TableA",
        '[dbo].[TableA]',
        "TableB",
        '[dbo].[TableB]',
    ),
    UID in DataTable.UID,
    {Date: DataCard1.Update}
)

 

 

Is this a limitation, expected behavior or bug with UpdateIf? The same method works in all other locations I have used it. 

I need to find a workaround that is the least obtrusive, which may be to move the Switch function outside and repeat the UpdateIf multiple times. 

1 ACCEPTED SOLUTION

Accepted Solutions

Thanks @Anonymous ,

Please Accept as Solution so other people with the same question can find it more readily. This also closes the thread.

View solution in original post

3 REPLIES 3
WarrenBelz
Super User
Super User

Hi @Anonymous ,

Try going a step further back and try this

Switch(
   BusinessUnit,
   "TableA",
   UpdateIf(
      '[dbo].[TableA]',
      UID in DataTable.UID,
      {Date: DataCard1.Update}
   ),
   "TableB",
   UpdateIf(
      '[dbo].[TableB]',
      UID in DataTable.UID,
      {Date: DataCard1.Update}
   )
)

I have had issues in the past with If statements (which is what Switch is) embedded "too far in"

 

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.

Anonymous
Not applicable

Yes, thank you. That is indeed the solution I chose. Unfortunately, with four data sources and more conditions than demonstrated here, it's extremely verbose. It is, however, working. 

Thanks @Anonymous ,

Please Accept as Solution so other people with the same question can find it more readily. This also closes the thread.

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

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