cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Anonymous
Not applicable

Choice field to default based on another choice field

Hi,

 

I would like to default a choice field based on another choice field. 

So question 1 has choice A and B, If A is selected then question 2 should default to C, and if B is selected then question 2 should default to D. 

 

I got around this before by changing the choice field to a text field and using the below code.

If(DataCardValue12.Selected.Value = "A", "C"); If(DataCardValue12.Selected.Value = "B", "D")

 

But this time around I can't do that. 

 

Can you please help with the code? 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: Choice field to default based on another choice field

@Anonymous 

I missed a few commas in my original post.  This will work.  I've tested the code.

 

Put this code in the Default property of the Card.

Switch(
  DataCardValue11.Selected.Value,
  "Regulatory Capital", {Value: "Balance Sheet"},
  "Impairments", {Value: "Income Statement"},
  "Economic Capital", {Value: "Balance Sheet"},
  "Non Financial", {Value: "Non Financial Risk"}
)

 

Make sure DefaultSelectedItems in the ComboBox has this code.

Parent.Default

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

 

View solution in original post

5 REPLIES 5
Highlighted
Super User
Super User

Re: Choice field to default based on another choice field

@Anonymous 

I will suggest changing from an IF function to the SWITCH function but really you can use either.  The reason your ComboBox is not populating is because it expects a record.  To ensure we are passing a record we must put { } brackets around the value to create a record.

 

Put this code in the DefaultSelectedItems property of the 2nd ComboBox.

Switch(
  DataCardValue12.Selected.Value,
  "A", {Value: "C"}
  "B", {Value: "D"}
)

 

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Highlighted
Anonymous
Not applicable

Re: Choice field to default based on another choice field

Hi @mdevaney, thank you so much for replying

 

It doesn't seem to work for me. Can you check if I made a mistake somewhere

Switch(
  DataCardValue11.Selected.Value
  "Regulatory Capital", {Value: "Balance Sheet"}
  "Impairments", {Value: "Income Statement"}
  "Economic Capital", {Value: "Balance Sheet"}
  "Non Financial", {Value: "Non Financial Risk"}
)

 

DataCardValue11 contains the options Regulatory Capital, etc. and I'm doing this in the Item default which has 3 choices Balance Sheet, Income statement and Non Financial risk. 

Highlighted
Super User
Super User

Re: Choice field to default based on another choice field

@MadelineDT
Can you please try putting this code in DefaultSelectedItems property per my suggestion, not Default?

Next, can you please confirm we are grabbing the expected value by putting DataCardValue11.Selected.Value in the text property of a new label.

—-
Please Accept as Solution if this post answered your question so others may find it more quickly. If you found this post helpful consider giving it a Thumbs Up.
Highlighted
Anonymous
Not applicable

Re: Choice field to default based on another choice field

Thanks for helping @mdevaney !

 

I added it to DefaultSelectedItems property but still no luck. 

 

My text field does grab the expected value

Highlighted
Super User
Super User

Re: Choice field to default based on another choice field

@Anonymous 

I missed a few commas in my original post.  This will work.  I've tested the code.

 

Put this code in the Default property of the Card.

Switch(
  DataCardValue11.Selected.Value,
  "Regulatory Capital", {Value: "Balance Sheet"},
  "Impairments", {Value: "Income Statement"},
  "Economic Capital", {Value: "Balance Sheet"},
  "Non Financial", {Value: "Non Financial Risk"}
)

 

Make sure DefaultSelectedItems in the ComboBox has this code.

Parent.Default

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

 

View solution in original post

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

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