cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Akbulut
Level: Powered On

Filter Combobox2 on Combobox1 selected value

Hi,

I have two lookup entity in dynamics crm like city and country fields.I created two combobox in PowerApps.I added lookup field of Country in City entity form.

Combobox1 contains Country datas and Combobox2 contains City datas.

 

How to filter Combobox2 datas on Combobox1 selected items?

 

Filter(Cities;new_countryname=ComboBox1.Selected.new_name).new_cityname

 

It doesnt work. Is there anyone who can help me about this matter?

 

Thanks a lot,

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Filter Combobox2 on Combobox1 selected value

Hi @Akbulut,

 

Could you please share a bit more about the error message with the formula that you provided within your app?

Further, could you please show more details about the your Country entity and City entity within your Dynamics crm?

 

I think there is something wrong with the formula that you provided. In addition, I think you have faced a data type incompatible error with the formula that you provided, is it true?

 

When you add a Lookup field ( of Country entity) within your City entity, actually, the Lookup field find the corresponding value within the Country entity using a unique GUID string (e.g. '6c118935-fcaf-e811-814b-70106fa93fc1') rather than a specific text value.

 

I have made a test on my side, please take a try with the following workaround:

 

Countries Entity:7.JPG

Cities Entity:8.JPGNote: The countryname field is a Lookup type field in my Cities entity.

 

App configuration as below:9.JPG

 

 

Set the Items property of the Combobox1 to following:

Countries     /* <-- On your side, you should type your Country entity name here */

 

Set the DisplayFields property and SearchFields property to following formula:

["new_countryname"] /* <-- on your side, you should type ["new_name"] */

Note: The Countries represents the Countries entity within my Dynamics 365.

 

Set the Items property of the Combobox2 to following formula:

Filter(
Cities,
_new_countryname_value=ComboBox1.Selected.new_countriesid
).new_cityname

Note: The _new_countryname_value represents the countryname field (Lookup type field) within my Cities entity. The new_countriesid represents the id property (system field) within my Countries entity.

 

On your side, you should type following formula:

Filter(Cities,new_countryname_value=ComboBox1.Selected.new_countriesid).new_cityname

Note: The new_countryname_value represents the Lookup field within your Cities entity, the new_countriesid represents the id property (primary key, the identifier of one record of your Country entity) of your Country entity.

 

The GIF image as below:Test1.gif

 

 

 

Best regards,

Kris

 

 

 

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Microsoft dinusc
Microsoft

Re: Filter Combobox2 on Combobox1 selected value

Hello @Akbulut,

At a glance, your formula looks correct. I assume you're running your app in a non-English locale so you use ";" instead of "," in the Filter formula, right?

Some questions:

1. What is the error that you get?

2. Can you try to bind the values used in your formula to labels to ensure you get the expected results?

    Label1.Text = First(Cities).new_countryname

    Label2.Text = ComboBox1.Selected.new_name

    Lavel3.Text = First(Cities).new_cityname

The 3 labels above should display the country name of the first record from "Cities" table, the corresponding country name from the ComboBox selected value and the city name from the "Cities" table. The names shoulb be in the same format (start/end spaces, letter case and so on).

 

Community Support Team
Community Support Team

Re: Filter Combobox2 on Combobox1 selected value

Hi @Akbulut,

 

Could you please share a bit more about the error message with the formula that you provided within your app?

Further, could you please show more details about the your Country entity and City entity within your Dynamics crm?

 

I think there is something wrong with the formula that you provided. In addition, I think you have faced a data type incompatible error with the formula that you provided, is it true?

 

When you add a Lookup field ( of Country entity) within your City entity, actually, the Lookup field find the corresponding value within the Country entity using a unique GUID string (e.g. '6c118935-fcaf-e811-814b-70106fa93fc1') rather than a specific text value.

 

I have made a test on my side, please take a try with the following workaround:

 

Countries Entity:7.JPG

Cities Entity:8.JPGNote: The countryname field is a Lookup type field in my Cities entity.

 

App configuration as below:9.JPG

 

 

Set the Items property of the Combobox1 to following:

Countries     /* <-- On your side, you should type your Country entity name here */

 

Set the DisplayFields property and SearchFields property to following formula:

["new_countryname"] /* <-- on your side, you should type ["new_name"] */

Note: The Countries represents the Countries entity within my Dynamics 365.

 

Set the Items property of the Combobox2 to following formula:

Filter(
Cities,
_new_countryname_value=ComboBox1.Selected.new_countriesid
).new_cityname

Note: The _new_countryname_value represents the countryname field (Lookup type field) within my Cities entity. The new_countriesid represents the id property (system field) within my Countries entity.

 

On your side, you should type following formula:

Filter(Cities,new_countryname_value=ComboBox1.Selected.new_countriesid).new_cityname

Note: The new_countryname_value represents the Lookup field within your Cities entity, the new_countriesid represents the id property (primary key, the identifier of one record of your Country entity) of your Country entity.

 

The GIF image as below:Test1.gif

 

 

 

Best regards,

Kris

 

 

 

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Akbulut
Level: Powered On

Re: Filter Combobox2 on Combobox1 selected value

Hi @v-xida-msft

 

That works.Thanks a lot.

 

Best regards.

Akbulut

rluo4
Level: Powered On

Re: Filter Combobox2 on Combobox1 selected value

Hi Kris,

 

I am doing a similar one where i want to filter Leaves based on the Company selected. I am using Dropdown in the Forms. 

 

Entity 'Leave Types': Description(Text), Company (Lookup), Leavetypeid (Unique Identifier)

Entity 'Company': Company Code(Text), Companyid (Unique identifier)

 

Step1: Drop Down1 => Filter(Companies,'Company Code' <> Blank()) --> This works

Step2: Label: DataCardValue8.Selected.Value  --> This works 

Step3: Filter('Leave Types', Company.Company = GUID(DataCardValue8.Selected.Value)).Description --> Delegation warning

 

Error received: Delegation Warning. The highlighted part of this formula might not work correctly with column cdm_companyid on large data sets. (See attached image of the warning)

 

Can you please advise how to get this working further ?

 

Regards

Sri

 

( see attached Image)

 

 

Helpful resources

Announcements
thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (6,801)