Hi, please could you advise me on combo box validation? I have created 6 combo boxes - 3 pairs of code and country.
I need to check whether:
1.Always, the first pair of codes and country is selected. (the first pair is mandatory for this request, another two pairs are optional)
The button on the bottom (create new request) should be disabled only if first pair of combo boxes is not selected.
2.Check whether provided code and country exist in my data source (excel on OneDrive). This is really important as I have to allow users to search/type/paste code, and the list is long. While my app was tested - it appeared that testers could have pasted anything, and it was not validated anyhow (well, the dropdown did not appear, but they didn't pay attention). So they were submitting empty requests.
I was trying to try simple text boxes, but there are some obstacles that I don't know how to overcome. If there is no value selected and if the value is non-existing -- I get the same message. I used IsEmpty, but it's not what I would expect. If there is no value - there should be no message, but when the value is incorrect - the message should be displayed.
Please take a look on the screenshot of my app.
// disabled both are not selected or error message visible
If(IsBlank(ComboBox1.Selected.Value) || IsBlank(ComboBox2.Selected.Value) || labelErrorMessage.Visible, DisplayMode.Disabled , DisplayMode.Edit)
!IsBlank(LookUp(YourDataSource, CodeColumn.Value = ComboBox1.Selected.Value && CountryColumn.Value = ComboBox2.Selected.Value))
if user selects codeCombobox=1 and countryCombobox=a and there is a single record where code=1 and country=a, error is displayed.
If there is a record where code=1 and country=b, error is not shown.
Hi @Alex_10 thank you for your help! The first part already helped me a lot. Could you please explain from the second code what will be:
YourDataSource - I do have one excel file with both - Code and Country in two different, defined tables there (respectively TableXCX and TableCountry). As I'm typing formula, I cannot choose from the prompt the whole excel as source, but only singe table. Can/should I concatenate them somehow or use slightly different formula?
CodeColumn.Value, CountryColumn.Value - I'm confused what should I type here. My Tables headers in this excel file are respectively: X_Code_ID and CountryCode. Should it look like: X_Code_ID.X_Code_ID?
each table is a datasource. so you have 2 datasources.
You have TableXCX and TableCountry.
How do these tables relate (depend on) each other? (primary/foreign keys?)
!IsBlank(LookUp(TableXCX , CodeColumnName.Value = ComboBox1.Selected.Value)) &&
!IsBlank(LookUp(TableCountry, CountryColumnName.Value = ComboBox2.Selected.Value))
Thanks, but it does not work as I suspected. I will leave it as it is and at some point it is fine too (more explanation to requesters needed). All formulas I've tried cannot handle the empty combo box vs. incorrect value in the combo box. If one way they work (against incorrect), it cannot handle the other (empty).
Check out the News & Announcements to learn more.
Did you know that you can visit the Power Query Forum in Power BI and now Power Apps
Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.
DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.