Fetching table's first row results in a "cyclic reference error"

Ben 61 Reputation points
2021-06-23T18:19:46.697+00:00

Hello,

I have a simple function that takes a value and attempts to find its name (identifier) by looking it up in #shared.

let
    Lookup = (value) => 
        Table.SelectRows(Record.ToTable(#shared), each [Value] = value),
    FoundEntry = Lookup(Text.AfterDelimiter) // the argument here is the function whose name we're trying to find
in
    // FindEntry // works fine
    // Table.FirstValue(FoundEntry) // raises 'Expression.Error: A cyclic reference was encountered during evaluation.' - why?
    FoundEntry{0} // raises 'Expression.Error: A cyclic reference was encountered during evaluation.' - why?

Using the input value to filter #shared (converted to a table) down to the corresponding row works fine. However, attempting to select the first row (FoundEntry{0}) or first value (Table.FirstRow(FoundEntry) from this table results in an "Expression.Error: A cyclic reference was encountered during evaluation" being raised.

This seems strange, as limiting the output returned to just the first row or first value doesn't seem to introduce anything obviously cyclic.

Any idea what's going on here?

Thanks,
Ben

Community Center | Not monitored
0 comments No comments
{count} votes

Accepted answer
  1. Ehren (MSFT) 1,781 Reputation points Microsoft Employee
    2021-07-22T18:01:04.477+00:00

    The error is happening because the current query is included in #shared, and is being accessed as part of the [Value] = value filter. I'm not sure why the error doesn't happen when only Table.SelectRows is called. To avoid the error, try filtering out the current query by name before accessing [Value].


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.