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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Consolidated table from different sources

Hi All,

 

I have condition to consolidate 2 tables from different sources become one table as in picture.

consolidate table.png

The consolidate table should have latest data so if same UID located must be replace with the newest record from either each table site A or B.

 

Is it possible to apply the condition in Power BI. Highly appreciate for the answer.

 

Thanks & Regards,

Supriatna

 

 

1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

1) Append both tables

2) Sort by date in descending order and use Table.Buffer to keep the sort order ( https://community.powerbi.com/t5/Community-Blog/Bug-warning-for-Table-Sort-and-removing-duplicates-in-Power/ba-p/810390 )
3) Check column "UID" and remove duplicates.

 

Removing duplicates should keep the topmost row, so with the sorting before this should achieve what you've requested.

But using Table.Buffer is essential, as otherwise the sort order might not be kept.

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

4 REPLIES 4
v-yiruan-msft
Community Support
Community Support

Hi @Anonymous ,

You can follow the below steps to achieve it:

1. Append queries for Site A and Site B table(For example: Site B append to Site A table) in Query Editor

Merge queryMerge query

2. Create 3 measures

A = CALCULATE(MAX('Site A'[Field A]),FILTER('Site A','Site A'[Update Date]=MAX('Site A'[Update Date])))
B = CALCULATE(MAX('Site A'[Field B]),FILTER('Site A','Site A'[Update Date]=MAX('Site A'[Update Date])))
C = CALCULATE(MAX('Site A'[Field C]),FILTER('Site A','Site A'[Update Date]=MAX('Site A'[Update Date])))

3. Create a table visual and drag UID, these new measures and Update Date onto Table visualcreate measures.JPG

Best Regards

Rena

 

 

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

@Anonymous - Hmm, ugly. @ImkeF any ideas on this one? I could potentially think of a DAX way of doing this but it wouldn't be particularly pretty.

 

You could try merging the tables on UID but give the second table's columns names that identify them as the second table. Create new columns that check which date is newer and then populate these new columns with the correct original columns. Then, select out these new columns as the final table.


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hi @Anonymous ,

 

1) Append both tables

2) Sort by date in descending order and use Table.Buffer to keep the sort order ( https://community.powerbi.com/t5/Community-Blog/Bug-warning-for-Table-Sort-and-removing-duplicates-in-Power/ba-p/810390 )
3) Check column "UID" and remove duplicates.

 

Removing duplicates should keep the topmost row, so with the sorting before this should achieve what you've requested.

But using Table.Buffer is essential, as otherwise the sort order might not be kept.

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

amitchandak
Super User
Super User

@Anonymous , append and group in power Query

https://radacad.com/append-vs-merge-in-power-bi-and-power-query

 

https://www.poweredsolutions.co/2019/07/30/grouping-rows-with-power-bi-power-query/

 

 

union and summarize in DAX

summarize(union(siteA,SiteB),UID, "Field A" , max(Table[Field A]), "Field B" , max(Table[Field B]), "Field C" , max(Table[Field C]), "Updated Date" , max(Table[Updated Date]))

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.