Search code examples
sharepointpowerappssharepoint-listpowerapps-formula

PowerApps compare Table values to Text


I have a collection with job titles and question id's called colFunctions. I want to compare the job titles in the collection to a single known job title (a text value) and return a list of question id's.

enter image description here

So for the function Jr. System Administrator I want to get a list with ID's of Q01 and Q03, but not Q02.

I have this so far, but it says I can't compare a table to a text value. How can I overcome this?

ClearCollect(
    colMatchedFunction,
    Filter(colFunctions,Function = Office365Users.UserProfileV2(galleryDirectReports.Selected.userPrincipalName).jobTitle).QuestionID
);

Solution

  • If Function is a text column in SharePoint, or a multi-select choice column? If it is a text column, you can use the in operator, which can check if a the text contains the given id:

    ClearCollect(
      colMatchedFunction,
      Filter(
        colFunctions,
        Office365Users.UserProfileV2(galleryDirectReports.Selected.userPrincipalName).jobTitle).QuestionID in Function 
    ));
    

    In a multi-select choice column, you can still use the in operator, this time to check if a value belongs to a table, checking it against the 'Value' property of the multi-select column (which returns the text value represented by the choice):

    ClearCollect(
      colMatchedFunction,
      Filter(
        colFunctions,
        Office365Users.UserProfileV2(galleryDirectReports.Selected.UserPrincipalName).jobTitle
            in Function.Value
    ));