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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
smpa01
Community Champion
Community Champion

MDX Query

@bcdobbs @AlexisOlson @GilbertQ @d_gosbell 

 

I have a requirement to produce a MDX only query(to be at par other PROD elements - unfortunately authored by predecessor in MDX). I am new to MDX and don't really like it. However, I am trying to satisfy the current business req rather the reinventing the wheel in DAX. 

 

My question is - in DAX query, I can write measures that can exist  within the scope of the query and not in the overall SSAS db and yet it will work. Such as

evaluate 
// only exists within the query scope and not in ssas db
var _date = max(calendar[date])
return summarizecolumns(dim1[col1],dim2[col2],"date",_date)

Can the same can happen for a MDX query so that the measure can only stay within the scope of query?

 

// the following works 
//when measureOne exists in Measures table in ssas db in PBI premium
//measureOne = max(calendar[date])
with member [Measures].[measureOntheFly] as
[Measures].[measureOne] 

select 
{[Measures].[measureOntheFly]} on columns,
{
crossjoin(dim1[col].members, dim2[col2].members)
} properties memeber_caption, memeber_unique_name on rows
from [model]

 

But how can I create a DAX measure on the fly (does not already exist) to be utilized in MDX query. Let's suppose I need a MAX measure. I tried this which did not work.

//measure does not exists
with member [Measures].[measureOntheFly] as
max([calendar].[date]) 

select 
{[Measures].[measureOntheFly]} on columns,
{
crossjoin(dim1[col].members, dim2[col2].members)
} properties memeber_caption, memeber_unique_name on rows
from [model]

 

Thank you in advance.


========================
Did I answer your question? Mark my post as a solution!
Proud to be a Super User
My Custom Visualization Projects
• Plotting Live Sound: Live Sound
• Beautiful News: Women in Parliament, Energy Mix, Shrinking Armies
• Visual Capitalist: Working Hrs
• Others: Easing Graph, Animated Calendar
MayViz Submissions
• Week 1: View
• Week 2: View
========================
1 ACCEPTED SOLUTION
2 REPLIES 2
smpa01
Community Champion
Community Champion

@d_gosbell  many thanks; works like a charm.


========================
Did I answer your question? Mark my post as a solution!
Proud to be a Super User
My Custom Visualization Projects
• Plotting Live Sound: Live Sound
• Beautiful News: Women in Parliament, Energy Mix, Shrinking Armies
• Visual Capitalist: Working Hrs
• Others: Easing Graph, Animated Calendar
MayViz Submissions
• Week 1: View
• Week 2: View
========================
d_gosbell
Super User
Super User

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.