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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply

Unable to reference the source table of a custom column without triggering a cyclic reference error?

Hi Community,

I've written a custom column in a table of data. The table is called 'Recordable Hours' and contains 'Client Name' as well as values for 'Decimal Time'. 

I would like the resulting custom colum named 'Total_Client_Time_for_the_Week' to show the total sum of 'Decimal Time' for all rows with the same 'Client Name'. So the outcome is that if the row has the same 'Client Name' it should also have the same value in 'Total_Client_Time_for_the_Week'.

The expression I've used is below.

 

 

Total_Client_Time_for_the_Week = 

let
client1 = "Recordable Hours"[Client Name] ,

rows = Table.SelectRows( #"Recordable Hours", [Client Name] = client1 ),

result = List.Sum(Table.ToList(rows[Decimal Time]))

in
result

 

 

I am getting Expression.Error: A cyclic reference was encountered during evaluation. 

Could you please assist me on how to achieve the intended values and get around this error?

 

Thank you!

 

2 ACCEPTED SOLUTIONS

@jaime_blackwell ,

 

You can create a custom column with something like:

 

let _name = [Client Name] in
 List.Sum(Table.SelectRows(#"Recordable Hours", each [Client Name] = _name)[Decimal Time])

 

Be sure that #"Recordable Hours" is the last step before the new column.



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



View solution in original post

v-lionel-msft
Community Support
Community Support

Hi @jaime_blackwell ,

 

Or create a calculated column.

Total_Client_Time_for_the_Week = 
CALCULATE(
    SUM('Recordable Hours'[Decimal Time]),
    ALLEXCEPT( 'Recordable Hours', 'Recordable Hours'[Client Name] )
)

v-lionel-msft_0-1605148430088.png

 

Best regards,
Lionel Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

7 REPLIES 7
v-lionel-msft
Community Support
Community Support

Hi @jaime_blackwell ,

 

Or create a calculated column.

Total_Client_Time_for_the_Week = 
CALCULATE(
    SUM('Recordable Hours'[Decimal Time]),
    ALLEXCEPT( 'Recordable Hours', 'Recordable Hours'[Client Name] )
)

v-lionel-msft_0-1605148430088.png

 

Best regards,
Lionel Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

camargos88
Community Champion
Community Champion

@jaime_blackwell ,

 

How are you using this query ?

If you call this query inside the same base table it will throw an error like that.

 

Can you show how you are using it ? Also, if possible share the pbix (masking any sensitive data).



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Hi, Thanks for your response. Yes I am trying to add this custom column into the base table. I need to see the result value for every row of this table. This will mean the same value may appear multiple times. Is there a way to achieve this without getting the error? (This is required for future calculations applied to each row individually.)

I don't think I can provide the PBX as removing all sensitive data would require removing all of the data sorry!

To further clarify, I need to know how to reference the current row when creating a custom column. For example, if I want to create a table containing all records that match 'Client Name' for the current row, how do I refer to the current row without getting the cyclic reference error?

@jaime_blackwell ,

 

You can create a custom column with something like:

 

let _name = [Client Name] in
 List.Sum(Table.SelectRows(#"Recordable Hours", each [Client Name] = _name)[Decimal Time])

 

Be sure that #"Recordable Hours" is the last step before the new column.



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



camargos88
Community Champion
Community Champion

@jaime_blackwell ,

 

Try this one:

Total_Client_Time_for_the_Week = 

let
client1 = "Recordable Hours"[Client Name] ,

rows = Table.SelectRows( #"Recordable Hours", each [Client Name] = client1 ),

result = List.Sum(rows[Decimal Time])

in
result


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Thank you for your suggestion. Unfortunately this still returns the error:

Expression.Error: A cyclic reference was encountered during evaluation.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.