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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Combine two columns from different tables in SSAS Tabular with DAX

Hi All,
I try to Combine two columns from different tables in SSAS Tabular with DAX. I had the follow code to get the two columns

 

=VAR A = CALCULATETABLE( SUMMARIZE(StockDetail,StockDetail[ProductCode]),FILTER(RELATEDTABLE(Product),Product[code]))
VAR B =CALCULATETABLE( SUMMARIZE(Product,Product[code]),FILTER(RELATEDTABLE(StockDetail),StockDetail[ProductCode]))
VAR result = A
RETURN result


At moment I only have one column, I would like to have a bridge table with the two columns "StockDetail[code]" and "product[code]".

thanks,

pm

1 ACCEPTED SOLUTION
v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ;

Try it.

Filtered Bridge = 
VAR _a= DISTINCT(UNION(VALUES(A[Itema]),VALUES(B[ItemB])))
var _add=ADDCOLUMNS(FILTER( _a,[Itema]<>BLANK()),"Item A",CALCULATE(MAX('A'[Itema]),FILTER('A',[Itema]=EARLIER([Itema]))),"Item B",CALCULATE(MAX('B'[ItemB]),FILTER('B',[ItemB]=EARLIER([Itema]))))
return SUMMARIZE( _add,[Item A],[Item B])

The final show:

vyalanwumsft_0-1653039948234.png


Best Regards,
Community Support Team _ Yalan Wu
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

6 REPLIES 6
v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ;

Try it.

Filtered Bridge = 
VAR _a= DISTINCT(UNION(VALUES(A[Itema]),VALUES(B[ItemB])))
var _add=ADDCOLUMNS(FILTER( _a,[Itema]<>BLANK()),"Item A",CALCULATE(MAX('A'[Itema]),FILTER('A',[Itema]=EARLIER([Itema]))),"Item B",CALCULATE(MAX('B'[ItemB]),FILTER('B',[ItemB]=EARLIER([Itema]))))
return SUMMARIZE( _add,[Item A],[Item B])

The final show:

vyalanwumsft_0-1653039948234.png


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

v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ;

Try it.

measure =
VAR A =
    SUMMARIZE ( StockDetail, StockDetail[ProductCode] )
VAR B =
    SUMMARIZE ( Product, Product[code] )
RETURN
    SUMMARIZE ( UNION ( A, B ), [code] )


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

Anonymous
Not applicable

Hi Yalan Wu,
Great your help, but I yould like to see the two columns side by side.Union gives me only one column. And by the way you can't put in the same column a stocklineID   and a productID

Cheers

Anonymous
Not applicable

Hi, amitchandak
At moment I'm using SSAS tabular. and I try to create a bridge table between
stockdetail table and Product that have the stockdetailID and productID.

amitchandak
Super User
Super User

@Anonymous, Are you using a live connection? Then I doubt that will work in power bi.


Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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 community update carousel

Fabric Community Update - June 2025

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