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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
ukeasyproj
Helper II
Helper II

trying to merge 2 columns together in power bi direct query mode but getting error

I am trying to merge 2 columns in a table together, but I am getting the following error:

 

"This step results in a query that is not supported in direct query mode"

 

My sql query:

 

let
Source = Sql.Database(ServerName, DatabaseName),
dbo_TT_Projects = Source{[Schema="dbo",Item="TT_Projects"]}[Data],
#"Filtered Rows" = Table.SelectRows(dbo_TT_Projects, each [AccountId] = AccountID),
#"Removed Other Columns" = Table.SelectColumns(#"Filtered Rows",{"ProjectID", "Name", "EndDate", "ActCompletionDate", "Duration", "StartDate", "CreationDate", "ProjectStatusID", "BillingType", "BillingAmount", "Progress", "CustomerID", "CreatorID", "EstimatedHours", "Budget", "PortfolioID", "Billed", "MD_ProjectFields"}),
#"Expanded MD_ProjectFields" = Table.ExpandTableColumn(#"Removed Other Columns", "MD_ProjectFields", {"ProjectDECIMAL0", "ProjectDECIMAL1", "ProjectDECIMAL2", "ProjectDECIMAL3", "ProjectDECIMAL4", "ProjectDATETIME1", "ProjectDATETIME2", "ProjectDATETIME3", "ProjectDATETIME4", "ProjectDATETIME5", "ProjectINT0", "ProjectINT7", "ProjectINT8"}, {"ProjectDECIMAL0", "ProjectDECIMAL1", "ProjectDECIMAL2", "ProjectDECIMAL3", "ProjectDECIMAL4", "ProjectDATETIME1", "ProjectDATETIME2", "ProjectDATETIME3", "ProjectDATETIME4", "ProjectDATETIME5", "ProjectINT0", "ProjectINT7", "ProjectINT8"}),
#"Renamed Columns1" = Table.RenameColumns(#"Expanded MD_ProjectFields",{{"ProjectINT7", "CancerID"}, {"ProjectINT8", "CardiacID"}}),
#"Renamed CustomFields" = Table.RenameColumns(#"Renamed Columns1",{{"ProjectDATETIME1", "Original End Date"}, {"ProjectDATETIME2", "Q1 End Date"}, {"ProjectDATETIME3", "Q2 End Date"}, {"ProjectDATETIME4", "Q3 End Date"}, {"ProjectDATETIME5", "Q4 End Date"}, {"ProjectDECIMAL0", "Original Estimated Hours"}, {"ProjectDECIMAL1", "Q1"}, {"ProjectDECIMAL2", "Q2"}, {"ProjectDECIMAL3", "Q3"}, {"ProjectDECIMAL4", "Q4"}}),
#"Renamed Columns" = Table.RenameColumns(#"Renamed CustomFields",{{"Name", "Project Name"}, {"StartDate", "Start Date"}, {"EndDate", "End Date"}, {"ProjectINT0", "Cost Center ID"}}),
#"Merged Columns" = Table.CombineColumns(Table.TransformColumnTypes(#"Renamed Columns", {{"CardiacID", type text}, {"CancerID", type text}}, "en-CA"),{"CardiacID", "CancerID"},Combiner.CombineTextByDelimiter("", QuoteStyle.None),"Merged")
in
#"Merged Columns"

1 ACCEPTED SOLUTION
v-yuezhe-msft
Employee
Employee

Hi @ukeasyproj ,

As other post, we have some limitations in DirectQuery mode, "Merge column" feature is one of the them.

To work around the issue in your scenario, you can merge columns by creating new columns using formulas as below, replace the following column names with your own column names.

MergeColumn = CONCATENATE(test[item],test[State])
Merge = CONCATENATE(test[item],CONCATENATE(",",test[State]))
1.png

 

 

Thanks,
Lydia Zhang

Community Support Team _ Lydia Zhang
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

10 REPLIES 10
Anonymous
Not applicable

I know this is an older thread but I thought I'd share my solution:

= [First Text] & " - " & [Second Text]

In the formula bar it looks like this:

= Table.AddColumn(#"Renamed Columns", "Merged Column", each [First Text] & " - " & [Second Text])

Hope that works for some people Woman Happy

This gave me the same error.  Anyone else?

Anonymous
Not applicable

I am also getting the same error. Were you able to solve it?

Yes,
#"Added Custom" = Table.AddColumn(fact_XYZ, "CompositeKeyName", each Text.From([KeyComponent1])&":"&Text.From([KeyComponent2])),

Then you can join on another table with the same composite key.

Anonymous
Not applicable

Thanks @jprdynamicapps , but it didn't work for me. 😞

 

fact_XYZ - which table do you refer in this component of the formula?

@Anonymous You would have to add this composite key to each of the tables that you want to join.

v-yuezhe-msft
Employee
Employee

Hi @ukeasyproj ,

As other post, we have some limitations in DirectQuery mode, "Merge column" feature is one of the them.

To work around the issue in your scenario, you can merge columns by creating new columns using formulas as below, replace the following column names with your own column names.

MergeColumn = CONCATENATE(test[item],test[State])
Merge = CONCATENATE(test[item],CONCATENATE(",",test[State]))
1.png

 

 

Thanks,
Lydia Zhang

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

The problem with this is that I can't sort it. I hope you find a way to merge columns in Direct Query.

 

Anonymous
Not applicable

I guess the best way to solve it is in your data model, I'm using direct query and couldn't solve it, I tried just changing the format of date but also didn't work.

Baskar
Resident Rockstar
Resident Rockstar

U r correct , In Direct Query mode we have some limitaion dude . first u have to check that 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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