microsoft / microsoft/Power-Fx

Accessing child collections from record scope

Open
#2,535 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
3.4k
Forks
358
Avg merge
10h 34m
Merged PRs (30d)
3

Description

I'm encountering an error when I try to reference a child collection within a table formula. I can reproduce it in pac cli, canvas apps and my own application consuming this library, so it's quite possibly my misunderstanding of the language but any advice would be appreciated.

I can successfully get the number of activities associated with a single contact using:

CountRows(First(Contacts).Activities)

However, if I try to replicate that within a collection of contacts, say all those with the first name "Mark":

Sum(Filter(Contacts, 'First Name' = "Mark"), CountRows(ThisRecord.Activities))

I get the errors:

Error 65-76: The specified column is not accessible in this context.
Error 45-77: The function 'CountRows' has some invalid arguments.

I understand that this is potentially an inefficient formula as it would require the CountRows to be executed for each individual contact, but as far as I can see the ThisRecord.Activities should be in scope at the point it's being used?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source files or tests are named. Start by reproducing the two formulas in the reported Power Fx contexts, then trace how record scope and child-collection access are handled for the nested CountRows call; done means determining whether the formula is supported and documenting or correcting the resulting behavior.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.