cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Capuchino
Helper I
Helper I

Combobox using if and 2 differents data source

Hello, 

 

I am trying to build a combobox with an If Statement, however it doesn't work as I have data coming from 2 different data source. 

 

Both formula of the if statement works separately but not together. 

 

is there a solution?

 

If(ToggleShipFrom.Value=false, Filter('REPORTING.V_IBP_POSSIBLE_LOC_REPUNIT', DESTPLANTDESCR= CBShipto.Selected.Result).SOURCEPLANTDESCR, RenameColumns('REPORTING.M_IBP_LOCATION'.LOCDESCR , "LOCDESCR", "Result"))

1 ACCEPTED SOLUTION

Accepted Solutions

I found the solution, the 2 column needed to have the same name

 

Capuchino_0-1656581089880.png

 Thanks @ilied84  for your help !

View solution in original post

10 REPLIES 10
ilied84
Frequent Visitor

Tried this out. You can use collections to solve this. So, if you have a toggle, you can add to OnChange:

ClearCollect(List1, Source1.item)

ClearCollect(List2, Source2.item)

 

Add any filtering you need, so you get the items you require.

 

Then the combobox items would be:

If(ToggleShipFrom.Value=false; List1; List2)

 

Remember to add those collections also in Screen1 (or whatever screenname you have) -> OnVisible, so you'll have the collections ready when the app is started. The collections are updated with the toggle.

Hello @ilied84 , 

 

Thank you for the idea... unfortunatelly it doesn't work. The combobox is still blank. Any other idea ?

 

Thanks in advance, 

Capucine 

It works for me. Maybe I explained it badly. Here's a more descriptive tutorial:

 

toggle1.PNG

Code for my toggle. As you can see, i'm getting data from two different sources. The point is to get one column of data from that source and make it a collection. In my case, i'm getting a column called "Title" from one source and a column called "KP" from another source.

 

 

combobox1.PNG

Code for my combobox. I simply check the value of the toggle, and fetch the collection (List1 and List2) based on the value.

 

 

true1.PNG

End result, if the toggle is "true".

 

 

false1.PNG

End result if the toggle is "false".

 

Hope this helps!

Hello, 

 

thanks for the detailed explication...  however it is still not working for me please find bellow the screen shot : 

 

Capuchino_0-1656574037343.png

 

Capuchino_1-1656574079862.png

 

Capuchino_2-1656574106728.png

 

ilied84
Frequent Visitor

Thanks for the pictures! If you go to File -> Collections, what data is showing in List1 and ListFull?

ilied84
Frequent Visitor

Nevermind, I think I know where the problem is. The problem is with this code:

Filter('REPORTING.V_IBP_POSSIBLE_LOC_REPUNIT', DESTPLANTDESCR= CBShipto.Selected.Result)

 

Power Apps is expecting a text, but that is not a text value. You can get around this by setting the selected result as a variable. So, select CBshipto combobox (or dropdown) and change the code in OnChange to this:

 

Set(ShipTo; CBShipTo.Selected.Value)

 

Then change the previous code to:

Filter('REPORTING.V_IBP_POSSIBLE_LOC_REPUNIT', DESTPLANTDESCR= ShipTo)

 

I think that will fix this.

 

 

Capuchino_0-1656579291500.png

Capuchino_1-1656579317161.png


Here are the 2 screen shot 

 

This is not fixing the problem...  CBShipto.Selected.Result is a text 

Capuchino_0-1656580257019.png

 

And If use only this formula it is working for my Combobox 

 

Capuchino_1-1656580494731.png

 

 

I found the solution, the 2 column needed to have the same name

 

Capuchino_0-1656581089880.png

 Thanks @ilied84  for your help !

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Check out the New Ideas Site

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (5,168)