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
pjmanuel
Frequent Visitor

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, @pjmanuel ;

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, @pjmanuel ;

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, @pjmanuel ;

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.

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

pjmanuel
Frequent Visitor

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

@pjmanuel, 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.

 

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.

Top Solution Authors