convert a MDX Calculation to DAX Calculation

46 Views Asked by At

help me please, I need to convert a MDX Calculation to DAX Calculation

tail({[Calendar].[Time].[dtDate].members},2).item(0)

I am trying to convert that mdx query to dax formula. is there any simple way to write dax formula for that mdx query?

1

There are 1 best solutions below

0
Amira Bedhiafi On

WHile I don't recommend this approach because DAX and MDX are different langugages.

So start by getting the maximum date from Calendar table, excluding any filters that might limit the dates considered. Then calculate the second-to-last date SecondMaxDate by finding the maximum date that is less than MaxDate.

VAR MaxDate = CALCULATE(MAX([dtDate]), ALL('Calendar'))
VAR SecondMaxDate = CALCULATE(MAX([dtDate]), FILTER(ALL('Calendar'), [dtDate] < MaxDate))
RETURN SecondMaxDate