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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Tihannah
Resolver I
Resolver I

DAX Help between 2 tables

I have 2 tables with the same measures, but producing different time periods - historical and current. So I need something like this for one of the measures:

 

Case when Table A[Type]=N/A and Table B[Type]<>N/A then Table B

 

 

9 REPLIES 9
v-eqin-msft
Community Support
Community Support

Hi @Tihannah ,

Sorry, but I'm a little confused by your description.  It seems like you used 'Append' rather than 'Merge'. Please take a look at the link to understand the difference bewteen these two actions.

9.17.FO.1.PNG

Here is my pbix file.

 

Did I answer your question ? Please mark my reply as solution. Thank you very much.
If not, please upload some insensitive data samples and expected output.

 

Best Regards,
Eyelyn Qin

 

 

Thank you for sending the pbix file. I did perform a merge and selected the following columns, but I did not get the same output as you. I merged on the following columns:

Customer ID

Location ID

Date

 

But when I looked, this did not look the same as mine:

= Table.NestedJoin(#"Table A", {"Emp"}, #"Table B", {"Emp"}, "Table B", JoinKind.LeftOuter)

 

So I have made the corrections and it is loading so we will see what happens. Thanks.

v-eqin-msft
Community Support
Community Support

Hi @Tihannah ,

When you have one or more columns that you’d like to add to another query, you merge the queries.
You could take a look at this document for further information.

9.17.fo.1.PNG

 

Did I answer your question ? Please mark my reply as solution. Thank you very much.

If not, please upload some insensitive data samples and expected output.

 

Best Regards,

Eyelyn Qin

 

The merge gave me one "type" column in the table. In your DAX, you have the Types distinguished as Table A and Table B. You also have both var ="N/A" when I need Table A=N/A and Table B<>N/A?

 

I'm not understanding how this merge separates the two. 

v-eqin-msft
Community Support
Community Support

Hi @Tihannah ,

According to my understand, you want to display Type based on value from two tables, right?

You could merge the two tables, then use the following formula:

flag =
VAR flagA =
    IF ( MAX ( 'Merge1'[Table A.Type] ) = "N/A", 1, 0 )
VAR flagB =
    IF ( MAX ( 'Merge1'[Table B.Type] ) = "N/A", 1, 0 )
RETURN
IF ( flagA = 1 && flagB = 0, MAX ( 'Merge1'[Table B.Type] ), BLANK () )

My visualization looks like this:

9.17.5.1.png

Did I answer your question ? Please mark my reply as solution. Thank you very much.

If not, please upload some insensitive data samples and expected output.

 

Best Regards,

Eyelyn Qin

 

@v-eqin-msft 

Okay,  wasn't familiar with the merge, but found it and performed the merge on the two tables, but I'm not understanding how the 2 table A.type and table B.type are both brought into the merge table? It's bringing in all like columns as one?

@v-eqin-msft 

 

Yes, this is what I'm trying to achieve, but the DAX 'merge1' part returned a syntax error.  When I removed the 'Merge1', it only returned blanks.

 

Error.PNG

 

Sample.PNG

 

Here is a sample.

amitchandak
Super User
Super User

@Tihannah , Ask is not very clear

there are way to copy data from one table to another

// work both 1-M and M-1

City Name = maxx(FILTER(geography,geography[City Id]=Sales[City Id]),geography[City]) //Agg you can change

 

//1 -M with active relation

Item Name = RELATED('item'[Brand])

 

//1 to M

Month Name = LOOKUPVALUE('date'[Month Year],'date'[Date],Sales[Sales Date])

Sorry, a bit confused. Not trying to copy data from another table. In both tables, I have the same list of people in the same category segments based on their activity during different time periods and they are rolled up into these categories. So Im basically saying, if these people were Non-Active in Table A and Active in Table B, give me their Activity segment from Table B. Does that make more sense? Column names are the same in both tables.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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