cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
kriggo15
Post Patron
Post Patron

ComboBox DefaultSelectedItems logic

I need some assistance with my logic to populate the DefaultSelectedItems of my combobox for a given record.

 

The combobox is sourced from a list of labels and their IDs:

ID

Name

ID1

Label1
ID2Label2
ID3Label3

 

I have another source that lists my records and respective IDs, along with their labels:

RecordIDLabelIDsLabels
1"ID1"Label1
2"ID2","ID3"Label2,Label3
3"ID1","ID2","ID3"Label1,Label2,Label3


This is my current code but it brings back the IDs instead of the Label Names.

 

RenameColumns(Split(LookUp(RecordLabel, SelectedRecord.RecordID = RecordID, LabelIDs), ","), "Result", "Name")

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
kriggo15
Post Patron
Post Patron

Well, I see my dumb mistake. I'm bringing back LabelIDs instead of Name. Issue resolved.

View solution in original post

2 REPLIES 2
kriggo15
Post Patron
Post Patron

Well, I see my dumb mistake. I'm bringing back LabelIDs instead of Name. Issue resolved.

View solution in original post

RandyHayes
Super User
Super User

@kriggo15 

Consider the following to make matching records for your DefaultSelectedItems property:

With(LookUp(RecordLabel, RecordID=SelectedRecord.RecordID),
    With({_ids: Split(LabelIDs, ","), _names: Split(Labels, ",")},
        ForAll(Sequence(CountRows(_ids)),
            {ID: Last(FirstN(_ids, Value)).Result,
             Name: Last(FirstN(_names, Value)).Result
            }
        )
    )
)

I hope this is helpful for you. 

_____________________________________________________________________________________
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!

Helpful resources

Announcements
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

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