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
Anonymous
Not applicable

Copy one column from one table in another table (tables have one column in common)

Hi,

 

I would like to copy one column from one table in another table. Both tables hable one column in common (Chat ID), although there might be some values in the table A that do not appear in the table B and for that I should get as a result "No Chat".

 

How should I do this?

 

Thanks,
JFB

8 REPLIES 8
v-yangliu-msft
Community Support
Community Support

Hi  @Anonymous ,

It may be related to the different formats of the columns associated with your two tables. 

 

This is about the merger related content, hope to help you:

https://docs.microsoft.com/en-us/power-bi/connect-data/desktop-shape-and-combine-data

 

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data

 

Best Regards,

Liu Yang

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

Anonymous
Not applicable

Hi,

 

I was trying but I actually did not manage, I do not know which is actually the problem.

The idea described simple is as follows:

 

column.PNG

so table B has some common values with table A via column "chat ID", and I would like to copy in table B one column from Table A (where as I said, they have in comun the Chat ID), although table A has more values than table B, so I should get just the values they actually share via Chat ID.

v-yangliu-msft
Community Support
Community Support

Hi @Anonymous ,

Use the lookupvalue function to describe your problem_ zit chat_ chat’[chat_ ID] is equal to stag_ zit chat_ daten’[Chat_ ID], "stag"_ zit chat_ chat’[routing_ behavior_ By_ Agent] contains multiple values, resulting in an error. Summarize is recommended.

 

This is about the summarize function https://docs.microsoft.com/en-us/dax/summarize-function-dax

 

For your second question, you can merge 'stag'_ zit chat_ chat’[chat_ ID] and stag_ zit chat_ daten’[Chat_ Change the format of ID] to consistent

 

If my answer is not what you need, can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

Best Regards,

Liu Yang

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

Anonymous
Not applicable

When trying the merge option, so that I can have all (or just one column) from the second table into the first one, it gives me error too.

and i do not know what can it be, because i checked and the column "chat id" is in number format, not in text as highlighted in the error:

Combine error.PNG

what can be happening here?

Anonymous
Not applicable

Hii!

Thanks so much for such a detailed answer. I am not able though to do it with any of the options.

With Vlookup, i get the following error:

Vlookup.PNG

Routing_behavior_by_agent: is the column I actually want to copy from the 1st table into the 2nd one.

chat_chat is the first table and chat_daten is the second one. Chat ID is the column that both tables have in common, although it does not correspond 100%, that means, they share some values. "chat_id" has more fields than "Chat_ID".

What am I doing wrong with Vlookup here?

v-yangliu-msft
Community Support
Community Support

Hi  @Anonymous ,

There are three ways you can use it:

1. Using the related function

Related =
RELATED(TableB[city])

v-yangliu-msft_0-1606353536853.png

2. Using the LOOKUPVALUE function.

LookupValue =
LOOKUPVALUE('TableB'[city],
TableB[ID],'TableA'[ID])

v-yangliu-msft_1-1606353536858.jpeg

3. Use the merge of power query

v-yangliu-msft_2-1606353536860.jpeg

Expand the table B and select the desired column

v-yangliu-msft_3-1606353536862.jpeg

Result.

v-yangliu-msft_4-1606353536864.jpeg

For related and lookupvalue documents, you can take a look at these:

 https://docs.microsoft.com/en-us/dax/lookupvalue-function-dax

https://docs.microsoft.com/en-us/dax/related-function-dax

 

You can downloaded PBIX file from here.

 

Best Regards,

Liu Yang

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

mahoneypat
Employee
Employee

You should consider merging your tables in the query editor on the ChatID column, to get all your fields into one table.  If not, you can use the RELATED() function to bring values from Table B to Table A (if A is on the 1 side of a 1:1 or 1:Many relationship on the ChatID columns).

 

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

I am trying with Lookupvalue, but the column which i want to copy "routing behavior" is not a number but a text, so this might be the reason of the error?

Apart from that, the column chat_id from table A  (chat_chat) and the column Chat_ID from table B (chat_daten), share some values, but the column chat_id has more fields than the column Chat_ID (i.e, this last one, has not all the chat ids).

 

Doubt.PNG

 

Which is the best way to do this?

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.