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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
smpa01
Super User
Super User

DAX query on different DB but same SSAS server

@lbendlin @TomMartens @GilbertQ @bcdobbs @parry2k @d_gosbell 

I have not learnt who are the SME on this and if you feel that there is someone else who can help me on this please don't hesitate to tag.
Sorry for the poor title. Let me demonstrate my question with an example.

 

If there are two SQL tables exist on different SQL databases (DB) but on the same server, SQL allows to perform queries between those tables from different DBs.

 

E.g.

if there are two databases on the same SQL server (server1)Db1 and Db2Db1 has a table called  tbl1with a column custId and Db2 has a table called tbl2 with a column custId , it is possible to write a query like this

 

select *
from Db1.dbo.tbl1 x
join Db2.dbo.tbl2 y on x.custId = y.custId

 

 

Is it possible to do the same in case of a SSAS server (e.g. PBI Premium Workspace)?

Let's suppose I have deployed two tables in the SSAS server called t1 and t2 with following structure

 

smpa01_0-1640373785285.png

 

smpa01_1-1640373813602.png

 

smpa01_2-1640374011437.png

 

smpa01_3-1640374046174.png

 

Is it possible to write a DAX query where I can perform  join/filtering between tables tbl t1 (from DB t1) tblt2 (from DB t2).

 

In normal circumstances if both tables are from the same SSAS DB, I am able to do this

smpa01_4-1640374336520.png

 

But I was just wondering, like SQL server if it is possible at all to perform this across tables from different DBs. I extensively use DAX queries on the SSAS server and if this is possible, it can unleash some serious powers on my side to solve some complex business problems for my client.

 

Looking forward to hearing from you please.

 

Merry Christams and happy holidays !!!

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
1 ACCEPTED SOLUTION
bcdobbs
Super User
Super User

I don't think you can do it directly like you're trying. 

The closest you could get is to follow @parry2k suggestion and drop both models into a composite model and publish to premium workspace. To an external xlma connection that then behaves as a single model on which you could run your natural join.

 

Would be amazing if you could query directly like you suggest in SSMS or DAX studio but I suspect given the work that microsoft have had to put in to make composite models function I'm not sure it is. Happy to be corrected though.



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

View solution in original post

13 REPLIES 13
parry2k
Super User
Super User

@smpa01 I don't see any workaround for this. 😞



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@smpa01 @bcdobbs exactly what @AlexisOlson suggested. That's what I was referring to, doing merge in PQ if two different datasets, if it is a single dataset then write DAX query 

 

Cheers!!

P



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k thanks for clarifying. I already knew that these tables can be brought over to PQ and do the rest, but I really want to bypass that and have the transformation on the server-side if possible. That is the original intent. Given PQ's performance issue, I really don't want to involve it, unless I absolutely have to.

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
AlexisOlson
Super User
Super User

This doesn't take advantage of them being on the same server, but you can load both tables and merge them in Power Query along these lines:

let
    Table1 = AnalysisServices.Database(Workspace, DB1, [Query="EVALUATE Table1"]),
    Table2 = AnalysisServices.Database(Workspace, DB2, [Query="EVALUATE Table2"]),
    Merged = Table.NestedJoin(Table1, "custID", Table2, "custID", "Table2", JoinKind.LeftOuter)
in
    Merged

I know this isn't exactly what you're looking for. It's not a Live or DirectQuery connection and isn't fully evaluated on the server side but might still be useful in occasional situations.

parry2k
Super User
Super User

@bcdobbs yes you can do it if you are using XMLA endpoint which @smpa01 was trying to do. I just tested it, connect it to the remote Power bI dataset using XMLA endpoint, and wrote the custom DAX query to get the result that I want. In theory, it is possible.

 

Follow us on LinkedIn

 

Learn about conditional formatting at Microsoft Reactor

My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k  okay but how do you define different db names within EVLUATE, unless I am dropping all those SSAS dbs (t1 and t2) in a pbix (like @bcdobbs suggested, thanks for that, test pending on my side) and publish that in workspace and try to use the dax query on that model.

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Do mean connect to a composite model via xlma endpoint and run query against that? Or have you found a way to bypass the composite model layer? If so could you send an example query?



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
bcdobbs
Super User
Super User

I don't think you can do it directly like you're trying. 

The closest you could get is to follow @parry2k suggestion and drop both models into a composite model and publish to premium workspace. To an external xlma connection that then behaves as a single model on which you could run your natural join.

 

Would be amazing if you could query directly like you suggest in SSMS or DAX studio but I suspect given the work that microsoft have had to put in to make composite models function I'm not sure it is. Happy to be corrected though.



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

@bcdobbs  apologies for the delay in getting back to this. @bcdobbs  this is a brilliant suggestion. Yes, can't make SSAS behave like SQL at this point of time (with different DB but on the same server). 

 

The workaround is to put the SSAS DBs on a composite model and then all the DBs are available for combined transformation/query. @bcdobbs  awesome !!! 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
parry2k
Super User
Super User

@smpa01 although try this, you have to use EVALULATE  to return the table

 

EVALUATE
NATURALINNERJOIN( <<first table>>, <<2nd table>>)

 

Follow us on LinkedIn

 

Learn about conditional formatting at Microsoft Reactor

My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@smpa01 Why would you do that? Isn't these tables are already joined in the model (Power BI dataset)?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@smpa01 if you are using Power BI or AAS as a data source, yes, you can combine models called composite models (mainly known as DQ over Power BI and AAS) you can read more here. I hope this is what you are looking for. Using DirectQuery for datasets and Azure Analysis Services (preview) - Power BI | Microsoft Docs

 

Follow us on LinkedIn

 

Learn about conditional formatting at Microsoft Reactor

My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k  thanks for looking into it. But this is not what I was looking for. I was not looking for a composite model at all.

 

I am looking forward to do something like this (if possible) so that I can utilize the same in dataflow as well.

(where table t1 is from DB t1 and table t2 is from DB t2- but both reside on the same SSAS server)

 

smpa01_0-1640376105478.png

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.