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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
o59393
Post Prodigy
Post Prodigy

How to convert MDX code to DAX code using import connection

Hi all

 

I need to connect to SAS database using a dax code.

 

o59393_0-1630351121824.png

 

How can I convert this MDX code below I have into dax?

 

SELECT {
[Measures].[Unit Cases AC],
[Measures].[Unit Cases RE]

}

ON COLUMNS,

NON EMPTY(
{[Ship From].[Operation].&[Central]}*
{[Ship From].[Region].&[Colombia/Venezuela]}*
{[Ship From].[Country].CHILDREN}*
{[Ship From].[Bottler Owner].CHILDREN}*
{[Ship From].[BU Ship From].CHILDREN}*

{[Period].[Month 445].CHILDREN}*
{[Period].[Year 445].&[2021]}*
{[Product].[L1.7 - Segment].CHILDREN}*
{[Product].[L1.5 - Category].CHILDREN}*
{[Product].[L1.3 - Trademark Category].CHILDREN}*
{[Product].[L1.1 - Beverage Product].CHILDREN}*

{[Package].[Container Material].CHILDREN}*
{[Package].[Container Type].CHILDREN}*
{[Package].[Primary Container Volume Capacity].CHILDREN}*
{[Package].[L1.4 - Refillability].CHILDREN}*
{[Package].[L1.5 - MS-SS].CHILDREN}*
{[Package].[BPP Code].CHILDREN}

) ON ROWS

FROM [Global]

WHERE (
{[Ship From].[ISSCOM Ship From].[Segment].&[Latin America]},
{[Sales Type].[Primary Sales Indicator].&[Y]},
{[Reporting View].[Reporting View].&[Operational View]}
)

 

Thanks!

6 REPLIES 6
o59393
Post Prodigy
Post Prodigy

Hi @TomMartens  and @Greg_Deckler 

 

Please forget the MDX part. I used live connection to the server:

 

o59393_1-1630356218642.png

 

Now, what I need is to create a single table taking some columns from a few tables below.

 

The reason of this merged table is to facilitate the model I want to create.

 

o59393_2-1630356257536.png

 

 

I used summarize to bring up a new table like this:

 

o59393_3-1630356369328.png

 

My question would be, how can I bring columns from different tables into my summarize function?

 

Below in green I have all the columns from [Package table] that are already in my new table above, but how can I incorporate the [Product table] columns for example? From what I see summarize can only work with one table at the time.

 

 

o59393_4-1630356574611.png

 

 

Thanks!

 

 

Anonymous
Not applicable

Hi @o59393 

I think Power BI Desktop doesn't support you to build calculated tables by dax if you use Live connection mode.

1.png

If you want to build calculated table by summarize, you can try import mode.

And if you want to get columns from other tables, for example you use summarize to get all rows from 

[Package table], then you want to calculate other columns from  [Product table]. You need to make sure there are related key columns in two tables like ID or others.

Then if you have build relationships between two tables. You can use related function.

Table = 
Summarize([Package Table],...
...
...
...,
"Column1 from [Product Table]",Related[Column1]
...
)

If you didn't build relationship between two tables. Try this code:

Table = 
Summarize("Package",...
...
...
...,
"Column1 from [Product Table]",calculate(sum/max("Product"[Column1]),Filter("Product","Procuct"[KeyColumn] = Earlier("Package"[KeyColumn])))
...
)​

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Greg_Deckler
Community Champion
Community Champion

@o59393 I would refer you to this artcile: Converting MDX to DAX – First Steps - SQLBI



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
TomMartens
Super User
Super User

Hey @o59393 ,

 

in Power BI Desktop, create a matrix visual.

Drag the measures (in MDX ... on columns) to the values bucket of the matrix visual.

Drag the columns to the rows, you have to filter for dedicated elements e.g., 'Central' in the visual level filter.

 

Create Slicers for all the columns used in the where section of the MDX query.

 

This should do the trick already.

 

Regards,

Tom 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Hi @TomMartens 

 

Not sure I understand, let me give some context.  I need to use a live connection and dax to create the table I need to import from the server.

 

This table is composed/merged of different ones that are held in an azure database.

 

Can my code above be transformed into dax? How would the syntax be then?


Thanks!

 

 

Hey @o59393 ,

 

from the screenshot of your initial post, it seems you are using an MDX statement to connect live to SSAS or are you really connecting to a SAS server.

 

After the connection is established, how does the field list look like?

You can't use DAX to connect to an SSAS Multidimensional server.

Why do you want to use DAX to create a table?

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.