wildcat89
wildcat89

Reputation: 1285

Cyclic Reference Error When Trying to Reference Previous Data in Table (FrontAPI)

In Power BI's Advanced Query Editor, what I'm trying to do is:

  1. Get the max value of the Event_Emitted_At column from a previously queried API call (the table has been previously generated and has data in it)
  2. Use the value from step 1 as the after parameter for an API call (as the API allows you to filter for results Emitted after a particular Unix timestamp.

Right now, I'm getting a A cyclic reference was encountered during evaluation. error.

This is a sample of the previously queried table:

previouslyQueriedTable

What I have so far is this project/query structure:

getLatestEmittedAt

This above function should just grab the max value from the FrontEmailEvents[Events_Emitted_At] table/column.

getAPIResults

This above function grabs the results of an API call, making use of Pagination.

Now with those two functions in place, we can start a while loop to query for all events from the API between the after parameter and before the current time's timestamp:

MainQueryBody

The code "looks" ok, but I think it's throwing the cyclic reference error because it's assuming that the query is starting from scratch every time? So, it doesn't "know" or realize that there's already data stored in the FrontEmailEvents table from a query that was run on a previous day.

How can I make use of an "old" datapoint to use in a future query?

(In case you haven't noticed, this is using the Front API).

UPDATE

It's the _func_get_latest_emitted_at that's throwing the error, so the function that's trying to grab the max value of the FrontEmailEvents table is what's causing the issue.

Upvotes: 0

Views: 125

Answers (1)

horseyride
horseyride

Reputation: 21318

You seem to want to return a record, so you have to do this

() as record=> let z=[A=List.Max(Table1[a])] in z

not this

() as record=> let z=List.Max(Table1[a]) in z

Or instead, return a number, not a record

() as number=> let z=List.Max(Table1[a]) in z

That said, not sure why you are bothering with the function at all since you are not passing any parameters. Just directly reference the List.Max where you need it

Upvotes: 1

Related Questions