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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
schwinnen
Helper V
Helper V

Append Queries Question

I have to do identical reports from 2 differerent PostgresSQL databases.  Ideally, I would be able to merge the two queries so that I just have to create the report once.  However, I would still like to be able to identify which database the information came from so I can filter.  One database is TEST and one is PRODUCTION.  They both have identical fields and there is nothing in the data that would indicate which database each record comes from.  

Anyone have any ideas on this?  Is there a way to indicate which database each record comes from that would also apply to new records when I refresh?

 

1 ACCEPTED SOLUTION

@schwinnen,

 

You may refer to the following post.

https://community.powerbi.com/t5/Desktop/displaying-source-table-name-in-append-field/td-p/485400

Community Support Team _ Sam Zha
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

5 REPLIES 5
petrovnikitamai
Resolver V
Resolver V

for example, if u get data from odbc

Try to create table with db_id like

pic_1.jpg

and add new column with subquery like

=Table.AddColumn(Source, "Custom", each Odbc.Query([db_name],"select * from table_name"))

Next step expand data and create new primary key, merge db_name and primary key table. 

Unfortunately, this model don't support scheduled update in power bi service.

 

PattemManohar
Community Champion
Community Champion

@schwinnen Try adding an additional field in your SELECT statement (using SQL Statment) option while importing. Something, similar to this...

 

SELECT c1,c2,'TEST' as DB FROM TEST.Table1

UNION ALL

SELECT c1,c2,'PRODUCTION' as DB FROM PRODUCTION.Table2

 





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

Proud to be a PBI Community Champion




Thank you.  I will try this when I have a chance.  It will be more complicated than what you have provided because the name of the databases and the tables contained within them are longer than what I stated earlier.  And as I am not an expert at SQL, I will have to figure out exactly how to write my statement. 

@schwinnen,

 

You may refer to the following post.

https://community.powerbi.com/t5/Desktop/displaying-source-table-name-in-append-field/td-p/485400

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

That worked.  Thank you very much!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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