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

Prepopulated value based on user

Hi all! Fairly new to PowerApps so forgive me if this is a stupid question. I'm currently trying to build an expense report app that has cascading dropdowns. Dropdowns work fine right now but I would like to add the ability to prepopulate one drop down based on who is currently logged in. So for example, if I am logged into the app, the Region drop down will say "Northwest". But if Bill is logged into the app, the Region drop down will say "Southwest." 

 

Is there a way to do this? 

 

Thank you in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Prepopulated value based on user

Hi @modernoddity ,

Do you want to populate the State and Distributor Dropdowns automatically based on the value within the Region Dropdown box?

 

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

Set the Default property of the Region Dropdown box to following:

 

If(
   User().FullName = "modernoddity",
"Northwest",
User().FullName = "Bill",
"Southwest",
User().FullName = "User3",
"xxxx",
... )

Set the Items property of the State Dropdown box to following:

Filter(
         YourExcelTable,
         Region = RegionDropdownBox.Selected.Value
)

Set the Items property of the Distributor Dropdown box to following:

Filter(
         YourExcelTable,
         Region = RegionDropdownBox.Selected.Value,
         State = StateDropdownBox.Selected.Value
)

Please take a try with above Filter function, then check if the issue is solved.

 

More details about Filter function in PowerApps, please check the following article:

Filter function

 

Best regards,

 

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

6 REPLIES 6
Super User
Super User

Re: Prepopulated value based on user

@modernoddity 

Yes indeed and welcome to PowerApps!

 

What you need to look at is the Default value for your DropDown or ComboBox.

Without knowing more about the data that populates the dropdown, I will assume it to be simple and here is the solution and/or concept to try:

In the Default property, set it to the following -

Switch(User().FullName,
       "modernoddity", "Northwest",
       "Bill", "Southwest",
       "somebodyelse", "somewhere else"
)

Of course, you will want to substitute the names above with "Real" names - and fully case sensitive too (in this scenario).

Now, this is highly subject to working or not working based on the data that the dropdown list is getting.  So, try this out and if you have problems, post back and provide the Items property for your DropDown

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
modernoddity
Level: Powered On

Re: Prepopulated value based on user

@RandyHayes This is great, thank you! Is there a way then to make my other drop downs dependent on what is in that box since it would not be reading data directly from the source? Right now I'm just testing things out and using a very simple excel spreadsheet (later will be using SQL) with  Region, State, and Distributor columns. When the user selects their region, the state drop down only shows them states associated with that region, and then the distributor drop down only shows them Distributors associated with that state. If I enter the code you provided into the default section, how do I associate the other two drop downs with that information or is that even possible. 

 

modernoddity
Level: Powered On

Re: Prepopulated value based on user

@RandyHayes I don't think I'm doing a very good job of explaining what I'm actually trying to do lol. Let me back up. 

 

Essentially, what I would like to do is somehow read who is currently logged in and display a value based on the specific user in the drop down. I will have the drop down marked as "view" so they won't be able to select another region. The other drop downs (state, distributor, etc) will still need to be dependent on the value in the Region box. I'd like to do this without having to manually enter all the different regions, states, etc because we have thousands upon thousands. I have it all saved in a spreadsheet currently. 

 

Thank you again for your help 

Super User
Super User

Re: Prepopulated value based on user

@modernoddity 

This is all very possible.  The key to being effective is to identify what is the limiting factor to each dependency. 

So, we started with the User to be "defaulted" to a Region.  That was easy enough (although you will want to do that in a way that is not "hard coded" into the App eventually).

But now...if we want to filter the State dropdown by the Region, what would be the connection between them?  And then, for distributor (I would assume would be based on state) what ties them together.

 

I envision a connection as such:

There exists a list of distributors and for each distributor there is a State column.

There exists a State List and for each state there is a Region column.

And - eventually, there is a User list and each user has a Region column.

 

So perhaps you see the ties here...the user has a region (Lookup(users, name=UserName).Region - default for region dropdown).   The States dropdown has an items filter of Filter(states, Region=DropdownRegion.Selected.Value). 

Then, the distributors dropdown has a filter of Filter(distributors, State=DropdownState.Selected.Value).

This way everything ties together and is dependent on each previous selection.

BUT...you need to have this correlation in your data.

 

Is that where you are?  Do you have this relationship between the data?  If so, then yes, you can definitely have all of this that you want.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Community Support Team
Community Support Team

Re: Prepopulated value based on user

Hi @modernoddity ,

Do you want to populate the State and Distributor Dropdowns automatically based on the value within the Region Dropdown box?

 

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

Set the Default property of the Region Dropdown box to following:

 

If(
   User().FullName = "modernoddity",
"Northwest",
User().FullName = "Bill",
"Southwest",
User().FullName = "User3",
"xxxx",
... )

Set the Items property of the State Dropdown box to following:

Filter(
         YourExcelTable,
         Region = RegionDropdownBox.Selected.Value
)

Set the Items property of the Distributor Dropdown box to following:

Filter(
         YourExcelTable,
         Region = RegionDropdownBox.Selected.Value,
         State = StateDropdownBox.Selected.Value
)

Please take a try with above Filter function, then check if the issue is solved.

 

More details about Filter function in PowerApps, please check the following article:

Filter function

 

Best regards,

 

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

modernoddity
Level: Powered On

Re: Prepopulated value based on user

Thank you both! This worked perfectly 🙂 

Helpful resources

Announcements
thirdimage

Power Automate 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

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (4,845)