Forum Discussion

simpkinspete's avatar
simpkinspete
Brass Contributor
Aug 03, 2022
Solved

Lists - column to show the department code for an individual listed in a person column

I have a list where I want to add an individual under a person column and have their respective department code automatically populate in a separate column for organization purposes. Is there a way to use a calculated column to reference that individual's AD attributes? 

  • simpkinspete Department property is available as an option in 'Show field' for people picker property. But you cannot use a people picker column in a calculate column calculations. Here is a workaround to try -

    • Create a text column called 'Emp name'
    • Update your person column to display Department value

    • Setup a power automate to run and fill in your 'Emp name' text column with 'Name' property accessible for people picker. 

    If you execute it properly, you will end up with Name and department properties. 

     

  • simpkinspete No, you cannot use person or group column value in calculated columns.

     

    You have two options: 

    1. Customize list form using power apps, get user profile information using office 365 users connector in power apps & update the column while saving the form
    2. Run power automate flow on item creation/update and update the column values using "Update item" action

    Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

  • Bharath Arja's avatar
    Bharath Arja
    Iron Contributor

    simpkinspete Department property is available as an option in 'Show field' for people picker property. But you cannot use a people picker column in a calculate column calculations. Here is a workaround to try -

    • Create a text column called 'Emp name'
    • Update your person column to display Department value

    • Setup a power automate to run and fill in your 'Emp name' text column with 'Name' property accessible for people picker. 

    If you execute it properly, you will end up with Name and department properties. 

     

    • simpkinspete's avatar
      simpkinspete
      Brass Contributor
      Ah! I didn't know about the Show field options for the people picker. Is there a way to change the Show field for a specific view?
      • ganeshsanap's avatar
        ganeshsanap
        MVP

        simpkinspete 

         

        If you want to store the department value in column & use it somewhere (like sort/filter/any custom solution) - best possible options for you are customizing the list forms using power apps (department value will shown immediately after list item created) or updating list item with department value using power automate on item creation/update (may take some time to show the department value until flow runs).

         

        If you just want to show the department in list view (no need to store the actual value in column), you can use the JSON formatting like: 

         

        {
          "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
          "elmType": "div",
          "txtContent": "=[$Name.department]"
        }

         

        Where replace "Name" with internal name of your person or group column. Follow this article to get the internal name of your column: How to find the Internal name of columns in SharePoint Online? 

        Output

        DocumentationSharePoint column formatting 


        Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

Resources