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
CL7777
Helper III
Helper III

merging tables with two+ columns in common and additionally filtering out duplicates in merged table

I am an advanced beginner dax user and am trying to do something above my head. I have tried so many ways to do it and it doesnt work.

 

First issue is that I have a table that has rental store transfer data on it ('rental data')

It looks like this:

Store      date         PartNum    quantity      Transaction #

1           10-2            AAA               -1                100

2            10-2           AAA                1                 100

3            11-6           BBB                -1                 101

4            11-6           BBB                 1                  101

 

This tabel shows that part AAA was transferred from store 1 to store 2 and part number BBB was transferred from store 3 to store 4 on the dates indicated.

 

From this table, Id like to create a table that looks like this

 

FromStore      ToStore       date         PartNum    quantity    transaction number

    1                        2           10-2            AAA               1               100

   3                         4            11-6           BBB                1               101

 

I have tried so many things and cannot get it to work. 

 

The second thing I would like to do is:

 Filter out any duplicate entries, as the original data set has some bad data. So, for example if in the first example table above, I had data that looked like the following data (below, Notice the duplicate entries for part number AAA on the same date), I would like to only include in my table the highest transaction number pair (101) and not include transaction 100.

 

Store      date         PartNum    quantity      Transaction #

1           10-2            AAA               -1                100

2            10-2           AAA                1                 100

3            10-2           AAA                -1                 101

4            10-2           AAA                 1                  101

 

Any help you guys could offer would be much appreciated!

3 REPLIES 3
v-chuncz-msft
Community Support
Community Support

@CL7777 

 

You may try using RANKXLOOKUPVALUE and FILTER.

 

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.
danextian
Super User
Super User

Hello @CL7777 ,

 

You may use the DAX formula below as a calculated column for your second requirement;

 

Is latest transaction = 
CALCULATE (
    MAX ( 'Table1'[Transaction #] ),
    ALLEXCEPT ( 'Table1', 'Table1'[PartNum] )
) = 'Table1'[Transaction #]

 

For your second requirement, additional info is needed. How would someone know which which among the stores a PartNum goes from and to if they have the same date and transaction #? For example, AAA could be from store 1 then moved to 2 or it could be the other way around. There must some kind of a field that indicates the chronological order of the transactions - a datetime/timestamp field perhaps.
 










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


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

HI, thanks for your response. to follow up with answering your question, you tell the direction of tranfer for the part number by the fact that the quantity is -1. So, if it has a -1 quantity, that is the store that it left and if it has a positive 1 quantity, that is the store it was transferred to. Ill try your formula for the other part and see if that does the trick, thank you,

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.