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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
charles_o
Helper I
Helper I

Data Manipulation, Fees and dates in a row

Hi guys!

 

I have data shown like this:

Picture3.jpg

 

Fee.1 is tied to Date.1

Fee.2 is tied to Date.2

 

Can anyone show me a way to link these pieces to each other or manipulate it into a somewhat similar format below?

 

 

Picture2.jpg

 

 

I have been manipulating it another way by unpivoting the 4 columns then adding a custom column. However I could not get the formula to work (below) and figured you guys might know a more basic solution.

 

= if [Attribute] = "Fee.1" and [Attribute.1] = "Date.2" then "0" else [Fee] + if [Attribute] = "Fee.2" and [Attribute.1] = "Date.2" then "0" else [Fee]

 

 

Thanks!

1 ACCEPTED SOLUTION

I would recommend to add this code as a new query and replace "Table1" by "FAM".

 

If you want to add the code within your FAM query, then you already have a source step and you should use my code from the second step onwards, with the first new step referencing your current last step in the query. And you need to add a comma at the end of the last line of your current query.

 

It is quite logical that you get a cyclic reference if you have a line Source = FAM in a query with the name FAM, as it is referencing itself. You can't use the output from a query as the input for the same query.

 

Exception: in Excel you can output query results to an Excel table and use that table as input for the same query. In that case there is no cyclic reference as the query is not referencing itself, but the table in Excel which are different objects: the query result is not the Excel table; the query results are output to an Excel table.

Specializing in Power Query Formula Language (M)

View solution in original post

7 REPLIES 7
MarcelBeug
Community Champion
Community Champion

You can merge the corresponding columns to nested records, then unpivot and expand the records:

 

let
    Source = Table1,
    One = Table.CombineColumns(Source, {"Fee.1", "Date.1"},each Record.FromList(_,type[Fee = Int64.Type, Date = date]),"1"),
    Two = Table.CombineColumns(One, {"Fee.2", "Date.2"},each Record.FromList(_,type[Fee = Int64.Type, Date = date]),"2"),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Two, {"name"}, "Attribute", "Value"),
    #"Expanded Value" = Table.ExpandRecordColumn(#"Unpivoted Other Columns", "Value", {"Fee", "Date"}, {"Fee", "Date"}),
    #"Removed Columns" = Table.RemoveColumns(#"Expanded Value",{"Attribute"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Removed Columns",{{"Fee", Int64.Type}, {"Date", type date}})
in
    #"Changed Type"
Specializing in Power Query Formula Language (M)

I am getting the error below.

 

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

That's because a cyclic reference was encountered during evaluation.

 

Please understand we are no clairvoyants.

Specializing in Power Query Formula Language (M)

Maybe the name of your query is Table1, which conflicts with Table1 in the Source step.

Specializing in Power Query Formula Language (M)

 

I am confused- is "Table1" not to be swapped for the name of my query? 

 

My query is named "FAM".My column names I want to join are: Date.1, Date.2, Fee.1, Fee.2 and they are in query "FAM"

 

When I use it with the "Source = Table1"

 

Expression.Error: The name 'Table1' wasn't recognized.  Make sure it's spelled correctly.

 

Which makes sense because there is no Table1, but if I rename it to my query "Source = FAM"

 

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

 

 This does not make sense to me, sorry if this is basic I am very new to Power BI

 

 

 

I would recommend to add this code as a new query and replace "Table1" by "FAM".

 

If you want to add the code within your FAM query, then you already have a source step and you should use my code from the second step onwards, with the first new step referencing your current last step in the query. And you need to add a comma at the end of the last line of your current query.

 

It is quite logical that you get a cyclic reference if you have a line Source = FAM in a query with the name FAM, as it is referencing itself. You can't use the output from a query as the input for the same query.

 

Exception: in Excel you can output query results to an Excel table and use that table as input for the same query. In that case there is no cyclic reference as the query is not referencing itself, but the table in Excel which are different objects: the query result is not the Excel table; the query results are output to an Excel table.

Specializing in Power Query Formula Language (M)

Thanks!

 

Sorry it took me a bit- just getting started with Power BI.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors