Hello everyone,
I have 2 dropdowns columns
Unit Make and Unit Model
Unit Make
A
B
C
D
E
F
G
H
I
J
and Unit Model
(should show up or auto selected if once Unit Make is selected)
for A
MZ
for B
T110
T220
for C
F200
F400
F600
for D
500
600
for E
MU600
for F
C6400
for G
5000
for H
330
for I
Act
for J
MD8
I made my canvas app(form) from SharePoint list(external data).
How can I make formula for above requirement.
I would be thankful for the help.
@MarkBandR Thanks much for the detailed explanation. I appreciate your kind help!
The example B is working perfectly fine.
___________________________________________________
For example A (would like to make it work also for my knowledge) -
I changed SharePoint list to Multiselect for the particular column. It removes all errors except 2 errors -
Hi @mtsts
I am wondering if maybe I misunderstood the initial question. I made the following assumptions:
Example A based on past information provided.
If "Make" is "C", then "Unit Model" should be set to "F200", "F400", and "F600". It would be set to all three of those values.
This is what the code I provided does.
If instead you are looking for,
When a User selects the "Make", the list of available choices for "Unit Model" should be limited to a subset of the total choices.
Example B:
If "Make" is "C", then the available choices for "Unit Model" should be limited to "F200", "F400", and "F600". The user would select ONE of those available values.
If you are looking for Example A, then your "Unit Model" field is probably NOT set to allow multiple choices. If you look at your field in SharePoint, it should be set to:
If you change it, you will need to Refresh the SharePoint List in your Power App to get it to pickup the change. If you are still having errors after you do this, you should copy your code for the DefaultSelectedItems to NotePad, delete the Unit Model Data Card, and re-add it to the Form so that Power Apps picks up the SharePoint Field correctly as a Multi-Choice field. Then paste back in your DefaultSelectedItems code.
IF you are looking for Example B, then you should set the "DefaultSelectedItems" back to "Parent.Default" and set the "Items" property of the "Unit Model" dropdown to just the "Switch" part of your code. This will limit the choices available for "Unit Model" based on the "Make".
-Mark
If I've answered your question or solved your problem, please mark this question as answered. This helps others who have the same question find a solution quickly via the forum search. If you liked my response, please consider giving it a thumbs up.
@MarkBandR Thanks much for helping. Here is my code. Giving me errors.
I tried with UnitModel also. It is giving me same errors -
Hi @mtsts , You can use the below code in the Onchange and Onselect properties of the Unit Make dropdown
Set (VarUnitMake,Self.Selected.Value);
Now, in the Items property of UnitModel use,
Switch (VarUnitMake, "A",["MZ"],"B",["T110","T220"],"C",["F200","F400","F600"])
and so on..
Let me know if this helps !
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
Hi @mtsts
You've got a lot going on there. You have an "If(" that is not connected to anything. You have "UnitModel1" and "UnitModel" in the formula.
Taking what you provided, the following worked for me after duplicating the changes you made to the choices for Make and UnitModel:
Coalesce(
Parent.Default,
Switch(
DD.Selected.Value,
"Ftry",
Filter(
Choices([@'New Service Write Up'].UnitModel),
Value = "M"
),
"Kenw",
Filter(
Choices([@'New Service Write Up'].UnitModel),
Value = "T7" Or Value = "T8" Or Value = "T9"
),
"Fouo",
Filter(
Choices([@'New Service Write Up'].UnitModel),
Value = "F5" Or Value = "F6" Or Value = "F7"
),
"Pete",
Filter(
Choices([@'New Service Write Up'].UnitModel),
Value = "58" Or Value = "48"
),
"Inte",
Filter(
Choices([@'New Service Write Up'].UnitModel),
Value = "M07"
),
"Ciot",
Filter(
Choices([@'New Service Write Up'].UnitModel),
Value = "C00"
),
"Dote",
Filter(
Choices([@'New Service Write Up'].UnitModel),
Value = "500"
),
"Hno",
Filter(
Choices([@'New Service Write Up'].UnitModel),
Value = "38"
),
"Ster",
Filter(
Choices([@'New Service Write Up'].UnitModel),
Value = "Ara"
),
"Ma",
Filter(
Choices([@'New Service Write Up'].UnitModel),
Value = "M7"
)
)
)
The UnitModel field had to be setup as a Multi-select Choice field for "Coalesce" to work.
So if I chose "Kenw" for "Make", it would show:
All of the available Choices are still in UnitModel:
If this has you going in the right direction, can you give a Thumbs Up?
-Mark
If I've answered your question or solved your problem, please mark this question as answered. This helps others who have the same question find a solution quickly via the forum search. If you liked my response, please consider giving it a thumbs up.
@MarkBandR Yes I am also looking to make a cascading set of drop downs where the choice from the first dropdown determines the available choices in the second dropdown.
Can you share the code for this as well.
________________________________________________________________________________________________
And I tried the later part code -
Coalesce(
Parent.Default,
If(
Switch(
DD.Selected.Value,
"Ftry",
Filter(Choices([@'New Service Write Up'].UnitModel1),Value = "M"),
"Kenw",
Filter(Choices([@'New Service Write Up'].UnitModel1), Value = "T7" Or Value = "T8" Or Value = "T9"),
"Fouo",
Filter(Choices([@'New Service Write Up'].UnitModel),Value = "F5" Or Value = "F6" Or Value = "F7"),
"Pete",
Filter( Choices([@'New Service Write Up'].UnitModel), Value = "58" Or Value = "48"),
"Inte",
Filter(Choices([@'New Service Write Up'].UnitModel),Value = "M07"),
"Ciot",
Filter(Choices([@'New Service Write Up'].UnitModel), Value = "C00"),
"Dote",
Filter(Choices([@'New Service Write Up'].UnitModel), Value = "500"),
"Hno",
Filter(Choices([@'New Service Write Up'].UnitModel), Value = "38" ),
"Ster",
Filter(Choices([@'New Service Write Up'].UnitModel), Value = "Ara"),
"Ma",
Filter( Choices([@'New Service Write Up'].UnitModel), Value = "M7")
),
)
)
)
It is giving me error -
It is unclear if you are looking to make a cascading set of drop downs where the choice from the first dropdown determines the available choices in the second dropdown
Or
if you are looking to set the second dropdown based on the choices in the first dropdown.
I assumed the latter.
This might work for the "DefaultSelectedItems" property of your "Unit Model" dropdown. This assumes your first dropdown is named "dd_Make".
Coalesce(
Parent.Default,
If(
EditForm1.Mode = FormMode.New,
Switch(
dd_Make.Selected.Value,
"A",
Filter(
Choices([@'YourListHERE'].Model),
Value = "MZ"
),
"B",
Filter(
Choices([@'YourListHERE'].Model),
(Value = "T110" Or Value = "T220")
),
"C",
Filter(
Choices([@'YourListHERE'].Model),
(Value = "F200" Or Value = "F400" Or Value = "F600")
)
//Repeat for other choices
)
)
)
This will only execute the Switch statement if the Form is in FormMode.New. Remove that line if you don't need it.
-Mark
If I've answered your question or solved your problem, please mark this question as answered. This helps others who have the same question find a solution quickly via the forum search. If you liked my response, please consider giving it a thumbs up.
Hi @mtsts
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.