question

Ben-5596 avatar image
0 Votes"
Ben-5596 asked Ben-5596 commented

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

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

power-query-not-supported
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Ehren avatar image
0 Votes"
Ehren answered Ben-5596 commented

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

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you, @Ehren!

0 Votes 0 ·