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

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Combine Two Different Fields

(0) ShareShare
ReportReport
Posted on by

@RandyHayes 

 

Hello,

 

This is a snapshot of my new request form. When the user selects a project number from the dropdown control on the far left, the Project Name and Program Manager/Product Engineer fields automatically populate. This is great if the person knows what project number to select, but if they only know the Project Name, the only option they have is to click on the button in the upper left to navigate to a screen that has the full project list they can search so they can figure out what the right number is. To make it easier on them, I would like to combine the Project Name with the Project Number if possible so the Project Number drop down reads something like "110062 - Maverick". Is that possible? If so, what info would you need from me so as to advise what the formula might look like? As with anything, there are probably a number of ways one could approach this issue so let me know if you can think of a better way. It is getting late so no need to respond tonight. Thank you- Teresa

 

ProjNumNameCombo.png

 

Categories:
I have the same question (0)
  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at
    Re: Combine Two Different Fields

    Hi @tagustin2020 

    Use AddColumns(datasource,"newcol", ThisItem.ProjectNumber&" - "&ThisItem.ProjectName) and you can choose newcol as the value to show in the dropbox window.

  • RandyHayes Profile Picture
    76,291 Super User 2024 Season 1 on at
    Re: Combine Two Different Fields

    @tagustin2020 

    Yes, very possible.  There are a couple of things that need to be taken into account.

    1) This is a New Request Form - what role does the dropdown play in reviewing the Request later?  In other words, does your Edit form of this request have a dropdown as well, or is this only found on the New Request form?

    I ask this because if it plays a role in editing, then we need to be sensitive to displaying the proper selection in the dropdown based on what is in the record.

    2) What is the Items property of the dropdown?  Also, how does Name and PM/PE derive its values (what is the Text property)?

     

    In general the approach that @Drrickryp presents is the route to take, but the above questions need attention before proceeding as implementing that formula by itself may lead you to other problems in other areas.

     

  • tagustin2020 Profile Picture
    on at
    Re: Combine Two Different Fields

    @RandyHayes 

    @Drrickryp 

     

    Thank you both for your replies. I have the New form on one screen and the Edit form on a different screen. I would like to have the Project Number - Project Name appear in both dropdowns so the user can make changes in the Edit screen if necessary. The reason I broke them up is because the Edit screen has a multi-tab interface and I didn't want to confuse the user as to which fields they need to fill in.

     

    NEW FORM Items property for the Project Number dropdown:

    ForAll(

        Sequence(CountRows('Project List')+1),

        {'Project Number': If(Value-1 = 0, "- Select One -", Last(FirstN(SortByColumns('Project List'.'Project Number',"Title"), Value-1)).'Project Number')}

    )

     

    EDIT FORM Items property for the Project Number dropdown:

    SortByColumns('Project List'.'Project Number',"Title")

     

    I have text value fields and read-only labels going for the Project Name and Project Manager fields. The reason for the read-only labels was to make sure the user couldn't make changes to them, but that was before I learned from one of Randy's videos that you can make data cards read-only. I was taught this solution by someone else, but maybe it is far more complicated than it needs to be? Since I am supposed to launch this app next week, I'm afraid of breaking things attempting extensive changes on my own, but am open as always to learning from you. I have attached detailed screenshots and formulas for all 3 fields as trying to paste them all here would be a bit unwieldy.

     

    Thank you in advance for your help,

    Teresa

     

     

  • RandyHayes Profile Picture
    76,291 Super User 2024 Season 1 on at
    Re: Combine Two Different Fields

    @tagustin2020 

    Very good (and as always...well documented- Thanks!!).  So what needs to be done is to add the information within the Items property of the dropdown control.

    Your formula should be this:

    ForAll(
     With({_items: SortByColumns('Project List'.'Project Number',"Title")},
     Sequence(CountRows(_items)+1, 0),
     With({_item: Last(FirstN(_items, Value))}, 
     {'Project Number': If(Value = 0, "- Select One -", _item.'Project Number'),
     NumberAndName: If(Value = 0, "- Select One -", _item.'Project Number' & " - " & _item.'Project Name')
     }
     )
     )
    )

    Now set the Value for the display field to "NumberAndName".  This will give you what you want without any impact to anything else.

    Note a couple changes I have made. 

    First is that I moved your SortByColumns on the project list into its own with variable.  You had it in the middle of the Last(FirstN( in your original formula before.  This change is a performance change as now the sort is done once instead of on every iteration of the sequence. 

    Second, I put another With in for the _item (the Last(FirstN bit), only because I would be referencing this item twice and I hate to repeat the same formula over and over. 

    Third, I changed the Sequence to start at 0.  This is just a little cleanup from my original video that you got this from - When I did the video I did not realize I could start the sequence at 0.  It is much cleaner that way.

     

    I had originally asked about the two labels on the screen.  I see the formulas in your document.  Those could stand some attention as you already have the values from the Dropdown, there is no need to do lookups for both of them to get the values.  BUT, this I did not address here and will only address should that become an issue for you.

     

    Give it a go and see how things look.

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at
    Re: Combine Two Different Fields

    I would trust @RandyHayes  over anyone in this forum regarding forms. He is my go to guy for them!

  • tagustin2020 Profile Picture
    on at
    Re: Combine Two Different Fields

    @RandyHayes 

     

    Hi Randy,

     

    Thank you for the advice and formula gift. I tried plugging the formula into the Items property of the dropdown control in the New form, but it doesn't seem to like it. Maybe its just because I haven't done part 2 yet? I'm not clear on what to do yet as I don't have a display field in the Project Number data card, only the dropdown control. Would you mind clarifying this part of the instruction? "Now set the Value for the display field to "NumberAndName"." Thank you, Teresa

    Error.png

  • RandyHayes Profile Picture
    76,291 Super User 2024 Season 1 on at
    Re: Combine Two Different Fields

    @tagustin2020 

    Yep, I am still waiting for the PowerApps formula editor brain plugin.  I typed that freehand and had a mix up...change to:

    With({_items: SortByColumns('Project List'.'Project Number',"Title")},
     ForAll(
     Sequence(CountRows(_items)+1, 0),
     With({_item: Last(FirstN(_items, Value))}, 
     {'Project Number': If(Value = 0, "- Select One -", _item.'Project Number'),
     NumberAndName: If(Value = 0, "- Select One -", _item.'Project Number' & " - " & _item.'Project Name')
     }
     )
     )
    )

     

    Sorry about that 😯 

  • RandyHayes Profile Picture
    76,291 Super User 2024 Season 1 on at
    Re: Combine Two Different Fields

    @tagustin2020 

    Oh and for the Display Value...either in the property editor pane on the right, set the Value of the Dropdown.  Or you can go to the properties list dropdown and set the value directly.  Personally I find it easier through the property pane in the designer.

  • tagustin2020 Profile Picture
    on at
    Re: Combine Two Different Fields

    @RandyHayes 

     

    Hi Randy,

     

    Thanks for the edited formula. I haven't plugged it in yet because I realized I'm probably going to screw up the project number column in my home screen gallery if I do. The Text property for the label is ThisItem.'Project Number'. Any advice on how to handle this potential conflict?

     

    GallerySS.png

     

  • tagustin2020 Profile Picture
    on at
    Re: Combine Two Different Fields

    @RandyHayes 

     

    Hi Randy,

     

    In regards to the Value property, I don't seem to have that option. When I first set up this form following the other tutorial, I deleted the Text input field and manually inserted a dropdown menu, versus replacing it by going into Edit Fields and selecting a control option from there. Is that what is making the difference?

    ValueDDSS.png

     

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 663 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 398 Super User 2025 Season 2

#3
developerAJ Profile Picture

developerAJ 235

Last 30 days Overall leaderboard