cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mtsts
Resolver II
Resolver II

how to make auto selection for options in dropdown 2 column based on drop down 1 in canvas app

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.

2 ACCEPTED SOLUTIONS

Accepted Solutions

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:

MarkBandR_0-1718314935155.png

All of the available Choices are still in UnitModel:

MarkBandR_1-1718314977097.png

 

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.

 

View solution in original post

Hi @mtsts 

 

I am wondering if maybe I misunderstood the initial question. I made the following assumptions:

  1. The user would select the "Make". The "Make" field is setup to only allow a single value to be chosen.
  2. Once the user selects "Make", the "Unit Model" is set. The "Unit Model" is set up to allow multiple values to be selected. It is NOT a single selection field.

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:

MarkBandR_1-1718378729832.png

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.

View solution in original post

7 REPLIES 7

Hi @mtsts 

 

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.

mtsts
Resolver II
Resolver II

@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 - 

mtsts_0-1718310586294.pngmtsts_1-1718310616911.png

 

 

 

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:

MarkBandR_0-1718314935155.png

All of the available Choices are still in UnitModel:

MarkBandR_1-1718314977097.png

 

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.

 

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.

@MarkBandR Thanks much for helping. Here is my code. Giving me errors. 

mtsts_0-1718375823535.png

mtsts_3-1718375971757.png

 

 

 

mtsts_1-1718375911560.pngmtsts_2-1718375933644.png

 

 

I tried with UnitModel also. It is giving me same errors - 

mtsts_4-1718376445073.png

 

Hi @mtsts 

 

I am wondering if maybe I misunderstood the initial question. I made the following assumptions:

  1. The user would select the "Make". The "Make" field is setup to only allow a single value to be chosen.
  2. Once the user selects "Make", the "Unit Model" is set. The "Unit Model" is set up to allow multiple values to be selected. It is NOT a single selection field.

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:

MarkBandR_1-1718378729832.png

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.

mtsts
Resolver II
Resolver II

@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 - 

 

mtsts_0-1718386392607.pngmtsts_1-1718386415031.png

 

 

 

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!   This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions in the Forums to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersNumber of SolutionsSuper UsersNumber of Solutions @anandm08  23 @WarrenBelz  31 @DBO_DV  10 @Amik  19 AmínAA 6 @mmbr1606  12 @rzuber  4 @happyume  7 @Giraldoj  3@ANB 6 (tie)   @SpongYe  6 (tie)     Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersSolutionsSuper UsersSolutions @anandm08  10@WarrenBelz 25 @DBO_DV  6@mmbr1606 14 @AmínAA 4 @Amik  12 @royg  3 @ANB  10 @AllanDeCastro  2 @SunilPashikanti  5 @Michaelfp  2 @FLMike  5 @eduardo_izzo  2   Meekou 2   @rzuber  2   @Velegandla  2     @PowerPlatform-P  2   @Micaiah  2     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 3:Community MembersSolutionsSuper UsersSolutionsPower Apps anandm0861WarrenBelz86DBO_DV25Amik66Michaelfp13mmbr160647Giraldoj13FLMike31AmínAA13SpongYe27     Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 4:Community MembersSolutionsSuper UsersSolutionsPower Apps DBO-DV21WarranBelz26Giraldoj7mmbr160618Muzammmil_0695067Amik14samfawzi_acml6FLMike12tzuber6ANB8   SunilPashikanti8

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (554)