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.
@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.
Solved! Go to Solution.
@d_gosbell many thanks; works like a charm.
You could use this technique https://blog.crossjoin.co.uk/2013/07/14/defining-dax-measures-in-the-with-clause-of-an-mdx-query/
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.