Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
JSBDodson
Frequent Visitor

Query Help - Create New Column with Value found in Row 1 of Column 2

I have an excel file I am using within Power BI that has a load date in  Row 1 of Column 2.

 

I have tried to use Create Custom Column using   ```  = #"Changed Type"[Column2]{0}  ```  to  create a new column with just the value of Row 1.  I would then fill down with this value to create a column that displays the load date for each row for use in calculations in the data.

 

When I try this I get an error:  "Expression.Error: A cyclic reference was encountered during evaluation."

 

I have also attempted extracting the date, turning that into a table and then merging the new table back in, but have not been able to get this 2nd solution to work either.  

 

Does anyone have a better solution that would work for this?  

 

If further information would help I am happy to answer any questions for clarification.

 

Thank you

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @JSBDodson 

 

I tried your second idea and found a workaround. You could refer to below steps.

 

1. Right click on the date cell and select Add as New Query.

050605.jpg

 

2. Convert the new query Column2 to List rather than Table.

050606.jpg

 

3. In original table, add a custom column = List.First(Column2). Then you will get the result.

050607.jpg

 

What is strange is that if I extract the date from the original table directly by using "= SampleTable{0}[Column2]" and repeat the last two steps, I will get the same error "Expression.Error: A cyclic reference was encountered during evaluation." I guess if we extract the value from the same query or with reference to the query, it will display this cyclic reference error. However, if we extract the data from an independent query, this error will not appear.

 

Hope this helps.

 

Regards,
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.

View solution in original post

7 REPLIES 7
v-jingzhang
Community Support
Community Support

Hi @JSBDodson , I find an easier method. Have a try!

 

= Table.AddColumn(#"Changed Type1", "Custom", each Record.Field(#"Changed Type1"{0}[[Column1]],"Column1"))

050703.jpg

Regards,

Jing

v-jingzhang
Community Support
Community Support

Hi @JSBDodson 

 

I tried your second idea and found a workaround. You could refer to below steps.

 

1. Right click on the date cell and select Add as New Query.

050605.jpg

 

2. Convert the new query Column2 to List rather than Table.

050606.jpg

 

3. In original table, add a custom column = List.First(Column2). Then you will get the result.

050607.jpg

 

What is strange is that if I extract the date from the original table directly by using "= SampleTable{0}[Column2]" and repeat the last two steps, I will get the same error "Expression.Error: A cyclic reference was encountered during evaluation." I guess if we extract the value from the same query or with reference to the query, it will display this cyclic reference error. However, if we extract the data from an independent query, this error will not appear.

 

Hope this helps.

 

Regards,
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.

watkinnc
Super User
Super User

It would be a new step:

LoadDate = Table.AddColumn(PreviousStepName, "NewColumnName", each [Column2]{0})


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!
HotChilli
Super User
Super User

"Could this be caused because I am trying to insert this step into query editor before some previously made queries?" - Not sure. 

To debug, I suggest removing all steps(copy the text somewhere into notepad so you don't lose it) except the initial source and the new column step.  See if that works.

JSBDodson
Frequent Visitor

When I try   = #"Changed Type"[Column2]{0}     I get   "Expression.Error: A cyclic reference was encountered during evaluation."    

 

The data I'm trying to pull is in Row 1 of Column2   (Column2 is the column name)

 

Could this be caused because I am trying to insert this step into query editor before some previously made queries?

I tried what you suggested = Table.AddColumn(#"PreviousStep", "NewColumn", each [Column1]{3})

I don't get any syntax error and the step is created, but the entire new column shows "Error".

Can you clarify why and help to resolve this ?

HotChilli
Super User
Super User

It should work if you've got the right reference to the previous step -> this bit #"Changed Type"

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors