cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JR-BejeweledOne
Super User
Super User

Get value where choice references the column name

This one is going to be a little odd I think.

 

I need to populate a label with the value where the column name matches the item in a choice field.

 

This list has 4 columns for 4 different phone numbers.

 

Business Number

Home Number

Mobile Number

Other Number

 

There is a choice field where the Primary contact number is specified.   Choices are:

 

Business Number

Home Number

Mobile Number

Other Number

 

I need to populate a label with the phone number where the column name matches the selection in the Primary Contact Number column.

 

Like this:

 

Primary Contact Number = Mobile Phone

Label:  Phone number in the Mobile Number Column

 

Primary Contact Number = Business Phone

Label: Phone Number in the Business Number Column

 



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.
1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@JR-BejeweledOne 

You should, but that is not a record, that is a column.

With(LookUp(ITSupportContacts, Title = LabelPCSupervisor.Text),
    'Primary Contact Number' & " - " &
    Switch('Primary Contact Number',
       "Mobile Number", 'MobileNumber',
       "Business Number", 'BusinessNumber',
       "Home Number", 'HomeNumber',
       "Other Number", 'OtherNumber'
    )
)

 

If you already have that record in some other control, I would just reference it in the above formula rather than re-looking up the record from the datasource.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

6 REPLIES 6
RandyHayes
Super User
Super User

@JR-BejeweledOne 

Consider the following:

 

With(<yourRecord>,
    Switch('Primary Contact Number',
        "Mobile Number", 'Mobile Number',
        "Business Number", 'Business Number',
        "Home Number", 'Home Number',
        "Other Number", 'Other Number'
    )
)

 

 

Not sure how you are getting your record, but just place it in the <yourRecord> part.

 

I hope this is helpful for you.

 

EDIT: sorry I see you only wanted the text instructions to show?? I kind of cut to the chase that it would be more efficient for the user to see the primary contact number in your label instead of instructions to look for it yourself.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
Ashwin7104
Responsive Resident
Responsive Resident

Hi @JR-BejeweledOne ,

 

Please add the below formula to text property of the label.

Concatenate("Phone Number in the ",Switch(Dropdown1.Selected.Value,"Mobile Number", "Mobile Number","Business Number", "Business Number","Home Number", "Home Number","Other Number", "Other Number")," Column")

 

Where Dropdown1.Selected.Value is the choice field.

 

Thanks.

That is what I want.   I need to show the phone number, but I need to show the phone number that is in the column that matches the primary phone number selection.



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.
RandyHayes
Super User
Super User

@JR-BejeweledOne 

That would be what the formula I provided will give you.

If you want it to be a little more "wordy", you could change to this:

With(<yourRecord>,
    'Primary Contact Number' & " - " &
    Switch('Primary Contact Number',
        "Mobile Number", 'Mobile Number',
        "Business Number", 'Business Number',
        "Home Number", 'Home Number',
        "Other Number", 'Other Number'
    )
)

This will also tell you what the primary contact is.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Should I be able to do a lookup to get my record like this?

 

With(Lookup(ITSupportContacts, Title = LabelPCSupervisor.Text).PrimaryAfterHoursPhone),
Switch('Primary Contact Number',
"Mobile Number", 'MobileNumber',
"Business Number", 'BusinessNumber',
"Home Number", 'HomeNumber',
"Other Number", 'OtherNumber'
)
)



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.
RandyHayes
Super User
Super User

@JR-BejeweledOne 

You should, but that is not a record, that is a column.

With(LookUp(ITSupportContacts, Title = LabelPCSupervisor.Text),
    'Primary Contact Number' & " - " &
    Switch('Primary Contact Number',
       "Mobile Number", 'MobileNumber',
       "Business Number", 'BusinessNumber',
       "Home Number", 'HomeNumber',
       "Other Number", 'OtherNumber'
    )
)

 

If you already have that record in some other control, I would just reference it in the above formula rather than re-looking up the record from the datasource.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,711)