web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to apply if condit...
Power Apps
Unanswered

How to apply if condition to select a datasource

(0) ShareShare
ReportReport
Posted on by 25

I have two sharepoint list- 'List 1' and 'List 2'. The fields for 'List 1' and 'List 2' are same. Fields are Category (choice Column- choices are 'Choice1', 'Choice2' and 'Both'), DateofSubmission (date column), Requester (name column), HighLevelKPI (text column).

 

I have customized 'List 1' form in power app and connected the form with two data connectors-'List 1' and 'List 2'. I need manually update the data source but is there a way we can apply a if condition and the data source value change automatically?

 

When a user saves the form, Can we apply a 'if' condition?, i.e., if 'Category' value chosen by the end user is 'Choice1', that entry will be updated in 'List 1'/DataSource is 'List 1' and if 'Category' value chosen by the end user is 'Choice2' , that entry will be updated in 'List 2'/DataSource is 'List 2' and if 'Category' value chosen by the end user is 'Both', the entry will be updated in 'List 1' and 'List 2'/DataSource is 'List 2' & 'List 1'.

Categories:
  • Fredrik_A Profile Picture
    3,644 Super User 2026 Season 2 on at

    Maybe something like this works? Set variables first:

     

    Button1: Set(variableDataSrc, 1);

    Button2: Set(variableDataSrc, 2);

     

    And then in items or where you want to use it do a switch:

     

    Switch(variableDataSrc,
              1, DataSource1,
              2, DataSource2)

  • kundup Profile Picture
    25 on at

    Is it possible not to use button1 and 2?

  • Fredrik_A Profile Picture
    3,644 Super User 2026 Season 2 on at

    Yes, you can switch the values of the variable where it suits your needs, it doesn't have to be buttons. 

  • kundup Profile Picture
    25 on at

    Thank you. But can you share a little bit more in details where should I set these variables- which property should I change? Where should I place that if condition and switch condition based on the "category' value? 

     

    I am very new to Power apps.

  • Fredrik_A Profile Picture
    3,644 Super User 2026 Season 2 on at

    Are there only 3 alternatives? List 1, list 2 or both?

    Is all you want to do patch/submit the value into the chosen list/lists?

  • kundup Profile Picture
    25 on at

    When the user saves a form, if the "Category" field value is "Choice1" (entered by the user), then the entry will go to Sharepoint list-'List 1"/f the "Category" field value is "Choice2" (entered by the user), then the entry will go to Sharepoint list-'List 2"/if the "Category" field value is "Both" (entered by the user), then the entry will go to 'List 1' & 'List 2'. 
    please note there are two sharepoint lists here

  • vikas1606 Profile Picture
    206 on at

    Hi @kundup ,

    You can switch datasource like the below on the From's data source.

    vikas1606_0-1679557465196.png

     

  • kundup Profile Picture
    25 on at

    DataSource= If([@'List 1'].Category.Value='Choice 2','List 1','List 2') - this is showing error.

     

    How should I correct it? Or do I need to update "OnSave" property with formula?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 382 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 329

#3
WarrenBelz Profile Picture

WarrenBelz 187 Most Valuable Professional

Last 30 days Overall leaderboard