cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Charlyvil
Frequent Visitor

Insert into SP list from ComboBox(multiselect) and Dropdown without repetitions

Hi friends. I'm starting and motivated with powerapps few days ago Smiley Very Happy but now I'm stuck:

 

I have a Dropdown(Items):

 

Distinct(Sort(colListaProcedimientos;nListaProcedimineto);nListaProcedimineto)

And a ComboBox(Items) with multiple select:

 

 

Puestos.Puesto

I got that values from another lists and I want to insert in another List('Procedimientos') but I don't want duplicated records. 

 

 

So for example:

List('Procedimientos'):

colA    _|_ colB

hello         world

hello         daddy

 

Insert: hello(from dropDown), world,Jenny(from comboBox)

 

Would be fail for world but for Jenny would be pass:

colA    _|_ colB

hello         world

hello         daddy

hello         Jenny

 

I'm trying this but don't works:

Set(item;First(Filter(Procedimientos;Procedimiento in comboBoxPuestos.SelectedItems.Puesto;nombrePuesto in Dropdown1.Selected.Result)));;
Patch(Procedimientos;item;{Procedimiento: Dropdown1.Selected.Result; nombrePuesto: comboBoxPuestos.Selected.Puesto})

Smiley Sad

 

Any ideas are welcome.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Charlyvil 

 

If you can create a lookup column to Puestos list in the Procedimientos list. This will make the relationship management much easier. Also, you have a option to allow mutliple selections, that way it could be done easily and properly.
 
Regarding displaying the value from the list, this can be done by using controls that supports table schema such as Gallery, Combobox controls etc. In case, you want to show a string value of all the selected options, then you can use the Concat() function to display the results.
 
Hope this Helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

11 REPLIES 11
yashag2255
Dual Super User II
Dual Super User II

Hi @Charlyvil 

 

To achieve this, you can create the expression as:
 
ForAll(
    ComboBox1.SelectedItems;
    If(
        CountRows(
            Filter(
                Procedimientos;
                ColB = Puesto && ColA = Dropdown1.Selected.Value
            )
        ) = 0;
        Patch(
            Procedimientos;
            Defaults(Procedimientos);
            {
                ColA: Dropdown1.Selected.Value;
                ColB: Puesto
            }
        )
    )
)
 
Here, Puesto is the name of combobox column.
 
Hope this Helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
Hooze
Helper I
Helper I

Deleting this because the above solution is FAR more efficient!

yashag2255
Dual Super User II
Dual Super User II

Hey @Charlyvil 

 

Were you able to resolve? 

 

Hey @Hooze 

 

Thank you for the comment, but I believe you should not have deleted your suggestion (it could give another perspective for everyone here to approach a problem-solution). 

 

Hope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

@yashag2255 

 

I suppose that is true.

 

Here is the solution I'd thought up, which I hope may be a helpful method or avenue of thought in other situations.

 

ClearCollect(DupCheck, AddColumns('Procedimientos', "DupFormat", Concatenate(Text(ColA),Text(ColB))));

Forall(ComboBox1.SelectedItems
     If(Not(Concatenate(Text(Dropdown1.Selected.Value),Text(Puesto)) in DupCheck.DupFormat),

Collect('Procedimientos', {ColA: Dropdown1.Selected.Value, ColB: Puesto})))

 

 

Hi and thanks for your solutions. I adapt the formula but don't works Smiley Sad :

ForAll(comboBoxPuestos.SelectedItems;
    If(
		CountRows(
					Filter(
							Procedimientos;
							nombrePuesto = Puesto && Procedimiento = 
                                                         Dropdown1.Selected.Result
							)
						)=0;
					Patch(Procedimientos;
					Defaults(Procedimientos);
					{
						Procedimiento:Dropdown1.Selected.Result;
						nombrePuesto: Puesto
					}
					)
		)
)

But I got duplicates sometimes and I don't know why:2019-09-16 22_08_18-Window.png

It's more frecuent in multiple selection.

I appreciate any contribution. Smiley Very Happy

Hi @Charlyvil 

 

Can you try to update your expression as:
 
ForAll(comboBoxPuestos.SelectedItems;
    If(
        CountRows(
                    Filter(
                            Procedimientos;
                            nombrePuesto = Puesto && Procedimiento =
                                                         Dropdown1.Selected.Result
                            )
                        )=0;
                    Patch(Procedimientos;
                    Defaults(Procedimientos);
                    {
                        ProcedimientoSmiley Very Happyropdown1.Selected.Result;
                        nombrePuesto: Puesto
                    }
                    );;Refresh(Procedimientos)
        )
)
 
Hope this Helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

I'm still having repetitions Smiley Frustrated. Your solution looks good, but I don't know what happen.

Do you have another recomendation to save the data. I only want the relation of two tables. (I was thinking on only one table and one cell have multiple values and then in powerapps split the information, but don't know if it's possible).

Hi @Charlyvil 

 

If you can create a lookup column to Puestos list in the Procedimientos list. This will make the relationship management much easier. Also, you have a option to allow mutliple selections, that way it could be done easily and properly.
 
Regarding displaying the value from the list, this can be done by using controls that supports table schema such as Gallery, Combobox controls etc. In case, you want to show a string value of all the selected options, then you can use the Concat() function to display the results.
 
Hope this Helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

I did all that you say. I have a little issue: I want search in a lookup value with múltiple values(displaying as a list). Some idea?

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (3,619)