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

Filter Table based on field in Second Table

i have two tables "Issues" and "Users" with a many-one relationship. Many on the issues table and one on the users Table, which is achieved by adding a lookup column (userid) into the issues Table. 

 

Users

Fields - userid, Name, Gender

Issues

Fields - issueId,userid,date_raised

 

i want to show the issues for only when the Gender of the user is Female. 

i tried this but i keep getting errors. any suggestions about how i can write this syntax would be appreciated

Filter(Issues, userid = Filter(users, Gender="Female").userid)

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Super User
Super User

Re: Filter Table based on field in Second Table

@Gottijay2000 

You might want to consider using the In operator for this.  Try this for your formula:

Filter(Issues, userid in Filter(users, Gender="Female").userid)

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.

View solution in original post

emh
Level 8

Re: Filter Table based on field in Second Table

Hello,

 

There are two options that can work. 

1) If you are using sql tables as your underlying data source, then you could create a view which performs the join in the CREATE VIEW definition:

SELECT u.userid, u.Name, u.Gender, i.date_raised

FROM dbo.Users u

INNER JOIN dbo.Issues i

ON u.userid=i.userid

 

2) You can perform the join within PowerApps using ShowColumns and AddColumns and then use this table result as your data source

 

ShowColumns(
    AddColumns(
        Users,
        "date_raised",
        LookUp(Issues, userid = Users[@userid], date_raised)),
    "userid", "Name", "Gender", "date_raised")

 

Hope this helps!

View solution in original post

6 REPLIES 6
Highlighted
Super User
Super User

Re: Filter Table based on field in Second Table

@Gottijay2000 

You might want to consider using the In operator for this.  Try this for your formula:

Filter(Issues, userid in Filter(users, Gender="Female").userid)

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.

View solution in original post

emh
Level 8

Re: Filter Table based on field in Second Table

Hello,

 

There are two options that can work. 

1) If you are using sql tables as your underlying data source, then you could create a view which performs the join in the CREATE VIEW definition:

SELECT u.userid, u.Name, u.Gender, i.date_raised

FROM dbo.Users u

INNER JOIN dbo.Issues i

ON u.userid=i.userid

 

2) You can perform the join within PowerApps using ShowColumns and AddColumns and then use this table result as your data source

 

ShowColumns(
    AddColumns(
        Users,
        "date_raised",
        LookUp(Issues, userid = Users[@userid], date_raised)),
    "userid", "Name", "Gender", "date_raised")

 

Hope this helps!

View solution in original post

Gottijay2000
Level: Powered On

Re: Filter Table based on field in Second Table

When i tried using the IN operator, this time i get an error with the "=" operator in the inner Filter function(ie Gender=Female"). the error say that it is an "invalid argument type"

Super User
Super User

Re: Filter Table based on field in Second Table

@Gottijay2000 

Check that your formula reads exactly as this:

Filter(Issues, userid in Filter(users, Gender="Female").userid)

That statement should work just fine (other than a warning for the potential for delegation errors on large data sources)

 

_____________________________________________________________________________________
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.
Gottijay2000
Level: Powered On

Re: Filter Table based on field in Second Table

many thanks, the gender field was actually a choice field so i changed the value from Gender to Gender.Value

Super User
Super User

Re: Filter Table based on field in Second Table

@Gottijay2000 

So this is a SharePoint choice column...yes, you will need the .Value

The solution you marked as your accepted solution for your question seems to indicate that you are working with SQL - perhaps you marked the wrong solution?

_____________________________________________________________________________________
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.

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 (5,569)