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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Column data = table name

I would like to append two tables, but I would like to be able to differenciate which data came from which table. Is there an easy way to pull the table name into the a column named "table" and use the table name as data? 

1 ACCEPTED SOLUTION

Add table name with your value using "Add Prefix" In Query Editor Window . Then you do the merging.

 

Eg. Vale = 103, Then Add "Table1" , O/P = Table1103

 

From the DAX  

Create new Column 

Value = MID(O/P,7,5) -- 5 give how long max digit u have 

 

Then u change the column datatype as Integer .

 

 

It will work.

 

 

View solution in original post

5 REPLIES 5
Seth_C_Bauer
Community Champion
Community Champion

@Anonymous Not within the editor that allows you to append, but you can create custom columns on each of the tables and just insert the table name.

 

In the Query editor select "Add Custom Column" 

Name the column (ex. TableName)

set the value = "<Your Table Name>" (ex.    ="Table1")

Do that for both tables

Append the queries.

 


Looking for more Power BI tips, tricks & tools? Check out PowerBI.tips the site I co-own with Mike Carlo. Also, if you are near SE WI? Join our PUG Milwaukee Brew City PUG
Anonymous
Not applicable

I tried that, but when I append the two tables it will only take the new column from the original table and will not add the new data from the other table for that column. 

@Anonymous

 

You need to add the custom column in Query Editor, not under Data tab.

 

Cap111ture.PNG

Cap333ture.PNG

 

Both tables need to add this table name column, then you can append correctly.

Captu77re.PNG

 

Regards,

Add table name with your value using "Add Prefix" In Query Editor Window . Then you do the merging.

 

Eg. Vale = 103, Then Add "Table1" , O/P = Table1103

 

From the DAX  

Create new Column 

Value = MID(O/P,7,5) -- 5 give how long max digit u have 

 

Then u change the column datatype as Integer .

 

 

It will work.

 

 

Add a custom column to each query before the Append with something like "=1" and "=2". The column name would be the same but when you import them, you know which row came from which original table.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.