cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Microsoft
Microsoft

Contains or SubString function?

Is there by chance a Contains or SubString function? Since I believe Office365.MyProfile() doesn't display if the current user is a Vendor or FTE, I was wondering if PowerApps has a way to determine if the Office365.MyProfile().Email or User().Email has the "v-" substring to determine whether or not they are a Vendor or FTE?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Power Apps
Power Apps

Re: Contains or SubString function?

There are several ways to accomplish this, the easiest of which is to use the "in" operator:

 

   "v-" in yourTextValue

 

You can also use the Find function:

 

   Find(find_text, within_text, optional start_index)

 

Yet another way to do it is to use the Left function:

 

  Left(yourTextValue, 2) = "v-"

 

 

 

Radu Gruian [MSFT] ** PowerApps Staff

View solution in original post

5 REPLIES 5
Highlighted
Power Apps
Power Apps

Re: Contains or SubString function?

There are several ways to accomplish this, the easiest of which is to use the "in" operator:

 

   "v-" in yourTextValue

 

You can also use the Find function:

 

   Find(find_text, within_text, optional start_index)

 

Yet another way to do it is to use the Left function:

 

  Left(yourTextValue, 2) = "v-"

 

 

 

Radu Gruian [MSFT] ** PowerApps Staff

View solution in original post

Highlighted
Microsoft
Microsoft

Re: Contains or SubString function?

Thanks for your response.

 

Now im running into the issue of trying to change the value of a drop down from an if statement using this logic.

 

If( "v-" in yourTextValue, "Vendor", FTE)

 

Power apps is complaining about expecting record values. How do I pull the record value from my dropdown?

Highlighted
Power Apps
Power Apps

Re: Contains or SubString function?

 

What are you binding your dropdown to?

 

Dropdowns, like listboxes and galleries, are typically bound to tabular data sources (tables), with one or more columns. The shell will make it possible for you to specify which of the columns/fields will be rendered in the dropdown. However, selecting one item will select the entire corresponding row of input.

 

For example, assuming that you have a data source Employees with the following fields: Name, Category, Title.

 

dropdown.Items = Employees

    Value = Name

 

The specifics of "Vendor" vs "FTE" will be part of your tabular data, and will show up in the dropdown automatically.

 

If on the other hand you just want to show a simple dropdown that lets you select between two options "Vendor" vs "FTE", do this instead:

 

dropdown.Items = ["Vendor", "FTE"]

 

It all depends on what your scenario calls for.

Radu Gruian [MSFT] ** PowerApps Staff
Microsoft
Microsoft

Re: Contains or SubString function?

So the scenario is we're pulling in a list from sharepoint and we want to automate the population of this dropdown field if possible where the options are "FTE" or "Vendor"

 

What we have is...

 

If("v-" in Office365Users.MyProfile().Email, DataCardValue.Items. = EmployeeType.Value = "Vendor", DataCardValue.Items. = EmployeeType.Value = "Vendor")

 

DataCardValue is our dropdown

EmployeeType is our tabular data source I guess

 

The condition I believe is correct the last two parts don't seem to work still based on your feedback

 

How can we switch the drop down to one of the tabular data sources, "FTE" or "Vendor"?

 

Highlighted
Power Apps
Power Apps

Re: Contains or SubString function?

The formula you pointed out seems syntactically incorrect. Just a quick reminder, PowerApps has a functional language, whereby each element declares where it draws its value(s) from; as opposed to an imperative language whereby each element would push value(s) into other relevant elements. This is similar to what happens in Excel: each cell declares where it draws its value(s) from, and how those values are composed to form the final value flowing into the cell.

 

Back to your example, it sounds like what you need is to populate the dropdown with a one-column table that contains two values: "Vendor", and "FTE".

 

- If you are using a Form, try changing the type of your field to "Choice" in Sharepoint, and specify what the choices are. PowerApps should pick up this metadata automatically, and the FTE/Vendor choices will show up in the resulting form / dropdown.

 

- If you are not using a Form but instead building a custom experience, then simply bind the dropdown to an inlined one-column table, like this:

    dropdown.Items = ["FTE", "Vendor"]

 

 

Radu Gruian [MSFT] ** PowerApps Staff

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Community Highlights

Check out whats happening in Power Apps

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 (9,859)