PowerApps set field value based on another field

In this PowerApps tutorial, We will discuss PowerApps set field value based on another field.

Also, we will see how to set multiple field values in a single field in PowerApps.

PowerApps set field value based on another field

By taking a simple example and a simple trick, I will explain how to set the field value in PowerApps based on another field.

Example:

I have a SharePoint Online List named “Access Registers“. This list has some columns with different data types.

Below screenshot represents the SharePoint List columns as:

set field value based on another field powerapps
  • In this list, I have a Department column with a Choice data type. These choice values are “IT“, “HR“, “FINANCE“, “ADMIN“, “VISITORS” etc.
  • Basically what I want to do is, When I will choose the Department value as VISITORS, then the Visitors Name (Single line of Text Data type) will store in the SharePoint List Title Field column.
  • Similarly, When I will choose the Department value as IT, HR, FINANCE, etc, then the Employee Name (Person Data type) will store in the SharePoint List Title field column.
  • Also, if you want to store the Employee Name with Department value, then easily you can store both the value in the SharePoint List Title field column.

For this requirement, I have a PowerApps Edit form where I have added all these SharePoint field columns. In this edit form, the Title field must be in hidden mode. Except for the Title field, all the fields should be in display mode.

The Powerapps Edit form looks like below:

powerapps set field value based on another field
powerapps set field value based on another field

From the above screenshot, you can see the Title field is in hidden mode and also you can see only the Employee Name. Normally, when you will choose the Department value as IT, HR, FINANCE, etc, then the Employee Name will appear.

And when you will choose the Department value as VISITORS, then the Visitors’ Name will display in the form.

When the user will fill all the fields and submit the form, then all the field values will store in the SharePoint List. At the same time, the Employee Name or Visitors Name will store in the Title Field in the SharePoint List.

Set Employee Name Field value in the Title Field using Power Apps (Based upon the Dropdown Selection Control):

Suppose, you want to choose the Department value as “VISITORS” and store the Visitors Name in the Title field, then follow the below things:

Add the Title Data card on the bottom of your form. Select the Text field of the Title Data card and Apply the below formula on its Default property as:

Default = If(DataCardValue3.Selected.Value="VISITORS",DataCardValue14.Text,DataCardValue15.Selected.DisplayName)

Where,

  • DataCardValue3.Selected.Value = Department DropDown field Name (As it is a Dropdown or Choice data type in SharePoint List, that’s why it specifies with “DropdownDatacardvalue.Selected.Value“).
  • DataCardValue14.Text = Visitors Name Data Card Value (As it is a single line of text data type in the SharePoint List, that’s why it specifies with “DataCardValue.Text“).
  • DataCardValue15.Selected.DisplayName = Employee Name Data Card Value (As it is a Person or People Picker Data type in SharePoint List, that’s why it specifies with “PersonDataCardValue.Selected.DisplayName“). Here, Instead of Display Name, also you can take Email, JobTitle, Department, etc.

This above formula specifies, if the Department value is Visitors, then it will store the Visitors Name otherwise it will store the Employee Name in the Title field.

You can refer the below screenshot:

set field value based on another field in powerapps
set field value based on another field in powerapps

Now just hide the Title field Data card from the Edit form. To hide this Title field, Select the Title card and apply false on its Visible property as shown below:

set field value based on another field in power apps

Preview the Powerapps app:

Save and Publish the app. Then Preview (F5) the app and choose the Department value as VISITORS. Enter the Visitor’s Name and other fields, then submit the form.

set field value based on another field powerapps
set field value based on another field powerapps

Now go to the SharePoint List (Access Registers). In that list, you can see the Visitors Name will be stored in the Title field as like the below screenshot:

set field value based on other field in power apps

Similarly, choose the Department value as IT, HR, or FINANCE. Enter the Employee Name and other fields, then submit the form.

set the field value based on other field in power apps
powerapps set field value based on another field

In that list, you can see the Employee Name will be stored in the Title field as like the below screenshot:

set the field value based on other field in powerapps

Set Employee Name Field and Department Field in the Title using Power Apps (Based upon the Dropdown Selection Control):

Let’s take the Department value as “VISITORS”. In the Title field, you want to store the Visitors Name including the Department value. That means the value will be stored as like “VISITORS-VisitorsName“. Follow these below things:

Add the Title Data card on the bottom of your form. Select the Text field of the Title Data card and Apply the below formula on its Default property as:

Default = If(DataCardValue3.Selected.Value="VISITORS",DataCardValue14.Text & "-" & DataCardValue3.Selected.Value,DataCardValue15.Selected.DisplayName & "-" & DataCardValue3.Selected.Value)

This above formula specifies, if the Department value is Visitors, then it will store the Visitors Name with a hyphen (-) and the Department value (VISITORS). Otherwise, it will store the Employee Name with a hyphen (-) and the Department value (IT) in the Title field.

Refer the below screenshot:

set the field value based on other fields in power apps

Now just hide the Title field Data card from the Edit form. To hide this Title field, Select the Title card and apply false on its Visible property as like previous one.

Preview the Powerapps app:

Save and Publish the app. Then Preview (F5) the app and choose the Department value as VISITORS. Enter the Visitor’s Name and other fields, then submit the form.

set the field value based on another field in powerapps

Now go to the SharePoint List (Access Registers). In that list, you can see the Visitors Name and Department value (Nancy-VISITORS) will be stored in the Title field as like the below screenshot:

set the field value based on another field in power apps

Similarly, you can do the same process for Employee Name also. When you will choose the Department value as “IT”, then it will store the value as like “EmployeeName-IT”.

Also, you may like these below PowerApps Tutorials:

In this tutorial, we learned how to set field value based on another field PowerApps. Also, we saw how to store multiple field values in a single field in PowerApps.

  • Hi Bijay,
    Thanks for the post. It is helpful.
    I however have an issue with another scenario. I have three fields.
    “Dropdown A”, “Dropdown B” and a “Multi select field C”.
    Dropdown A has values: Green Yellow, Red.

    My requirement is that, when “Red” is selected in dropdown A, the data in “Dropdown B” and “Multi select field C” should be cleared out.
    I have written the following formula to the Reset property of the Data Card Value of B and C: If(DataCardValue11.Selected.Value=”RED”,true, false)

    However, this works fine on a new form but on the edit of an existing entry, it is not working when I change from Green or Yellow to Red. Can you please help me on this issue?

  • >