cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Gottijay2000
Advocate II
Advocate II

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
RandyHayes
Super User III
Super User III

@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.
Check out my PowerApps Videos too!

View solution in original post

Anonymous
Not applicable

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
RandyHayes
Super User III
Super User III

@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.
Check out my PowerApps Videos too!

View solution in original post

Anonymous
Not applicable

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

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"

@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.
Check out my PowerApps Videos too!

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

@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.
Check out my PowerApps Videos too!

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Apps Community Call

Monthly Power Apps Community Call

Did you miss the call?? Check out the Power Apps Community Call here!

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (29,006)