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

CountIf and FIlter Cannot compare Detail List FK with Master ID

hello.

 

I have two Sharepoint lists - a Master List and a Detail List.  The Detail List has a Link Field that references the Master List's ID.  I had wanted to show the number of detail rows in a summary view of the Master List.

 

I want to use the expression

CountIf(LabVisitDetails, ThisItem.ID=LabVisitDetails.LabVisitMasterID)

to set a label in a gallery.

But powerApps studio marks the equals sign in my formula as an error.  The error message is "Invalid argument type" .  I've tried various comparisons in place of "=", but to no avail.

 

Is there some special syntax, or a member of either term in the equals test that I should use here?

2 ACCEPTED SOLUTIONS

Accepted Solutions
Super User III
Super User III

Is LabVisitMasterID a numeric column or a Lookup?  I am assuming when you say "Link Field" you are talking about a "Lookup Column".

 

If it is a lookup column, then you need your syntax to look like this:

 

      CountIf(LabVisitDetails, LabVisitMasterID.Id=ThisItem.ID)

 

_____________________________________________________________________________________
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

Advocate IV
Advocate IV

I believe I may myself have found out how to do this. The Master List is the data in the Gallery, and the Detail List is to provide a Count of Visit Details for informational purposes.

 

The problem was as I surmised earlier due to a failure to reference the correct Member of the Link Field.

CountIf(LabVisitDetails, LabVisitDetails[@LabVisitMasterID].Id = ThisItem.ID)

In this version, I use the full reference to the Link Field In LabVisitDetails  (LabVisitDetails[@LabVisitMasterID]) and then reference the Id member of the Link Field.  This gets tested against ThisItem.ID. The CountIf runs, and emits the expected number of detail records

 

View solution in original post

2 REPLIES 2
Super User III
Super User III

Is LabVisitMasterID a numeric column or a Lookup?  I am assuming when you say "Link Field" you are talking about a "Lookup Column".

 

If it is a lookup column, then you need your syntax to look like this:

 

      CountIf(LabVisitDetails, LabVisitMasterID.Id=ThisItem.ID)

 

_____________________________________________________________________________________
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

Advocate IV
Advocate IV

I believe I may myself have found out how to do this. The Master List is the data in the Gallery, and the Detail List is to provide a Count of Visit Details for informational purposes.

 

The problem was as I surmised earlier due to a failure to reference the correct Member of the Link Field.

CountIf(LabVisitDetails, LabVisitDetails[@LabVisitMasterID].Id = ThisItem.ID)

In this version, I use the full reference to the Link Field In LabVisitDetails  (LabVisitDetails[@LabVisitMasterID]) and then reference the Id member of the Link Field.  This gets tested against ThisItem.ID. The CountIf runs, and emits the expected number of detail records

 

View solution in original post

Helpful resources

Announcements
News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

Power Apps Community Call

Power Apps Community Call- January

Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST

PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

Top Solution Authors
Top Kudoed Authors
Users online (6,488)