MDX CurrentMember with SSAS 2008 doesn't work as stated by MSDN - ssas

First of all I use the SQL Management Studio for this query (no Excel 2007 that seems to have problems):
WITH
SET [Project period dates] AS
{
StrToMember("[Time].[Date].&[" + [Project].[ParentProject].CURRENTMEMBER.PROPERTIES("Project Start Iso") + "]"):
StrToMember("[Time].[Date].&[" + [Project].[ParentProject].CURRENTMEMBER.PROPERTIES("Project End Iso") + "]")
}
MEMBER [Measures].[Test] AS ([Project period dates].COUNT)
SELECT
{
[Measures].[Test]
}
on 0,
NONEMPTY ([Project].[ParentProject].MEMBERS)
DIMENSION PROPERTIES [Project].[ParentProject].[Project Duration], [Project].[ParentProject].[Project Start Iso], [Project].[ParentProject].[Project End Iso]
on 1
FROM
[MyCube]
WHERE
(
[Orgunit].[Orgunit].&[448]
)
This query delivers a list of projects with its three properties and a calculated member that is based upon my calculated set. The properties show the right values, but the calculated member shows always the same: the result of the very first project it should be calculated for.
I don't really understand why, because MSDN says:
The current member changes on a hierarchy used on an axis in a query.
Therefore, the current member on other hierarchies on the same
dimension that are not used on an axis can also change; this behavior
is called 'auto-exists'.
They give examples with calculated members, but I think that should also work with calculated sets, I have read that query-based calculated sets are dynamic by nature. Maybe somebody can tell me if I understood that wrong or what else is my problem here.

The named set are only computed once within a query. That is why your calculated member always return the same value.
You just have to remove the named set from your query:
MEMBER [Measures].[Test] AS {
StrToMember("[Time].[Date].&[" + [Project].[ParentProject].CURRENTMEMBER.PROPERTIES("Project Start Iso") + "]"):
StrToMember("[Time].[Date].&[" + [Project].[ParentProject].CURRENTMEMBER.PROPERTIES("Project End Iso") + "]")
}.COUNT

Related

MDX linkmember equivalent in DAX

Is there any equivalent of linkmemeber from MDX to DAX?
I am trying to migrate the following script from MDX to DAX
with
member TauxdetransformationQuartileRegion as ([Measures].[Taux_de_transformation_Region],[Bon Envoi].[Bon Envoi].&[True])
member Annees as [Date Creation].[Année].currentmember.name
select {
[Measures].[Tx_Real_Meilleur_Region]
,TauxdetransformationQuartileRegion
} on 0
FROM ( select strtoset(#Region) on 0 from test)
WHERE (
linkmember(strtotuple(#DateFin),[Mois Publication].[Mois de publication])
,{strtotuple(#DateDebut):strtotuple(#DateFin)}
,[Perimetre Ebusiness].[Périmètre E-Business].&[O]
,{[MER_Publication].[Detail Type Visiteur].&[Prospect],[MER_Publication].[Detail Type Visiteur].&[Client direct]}
,( - { [Origine_Marketing].[Entree Parcours].&[SiteAgent] } )
)
MDX query parameters are typically strings with member unique names ("[Dim].[Attr].&[Key]") which you must convert to a member with StrToMember(#Param). And if you need to switch hierarchies you the use LinkMember.
DAX parameters are just the values. So the parameter will work against any dimension. Thus LinkMember isn’t needed.
Here is an article about DAX parameters. For Date type parameters I forget if you just say 'Date'[Date] = #DateParam or if you have to say 'Date'[Date] = DATEVALUE(#DateParam). My recollection is that it depends on whether the parameter is Date type (use the first approach) or String type (use the DATEVALUE approach).

icCube - function calling another function results in NULL

Below the MDX statement on icCube. (Note that icCube has a non-native language component, called function).
with function article_list() as topcount([Product].[Product].[Article], [amount], 10)
function benchmark_best_index2(i) as sum(order(topcount([Product].[Product].[Article], [amount], 10), [measures].[amount], desc).(i-1) , [measures].[amount])
// why doesnot the following function work?
function benchmark_best_index(list,i) as sum(order(list, [measures].[amount], desc).(i-1), [measures].[amount])
member [measures].[bm_top_amount_doesnotwork] as benchmark_best_index(article_list(),1)
member [measures].[bm_top_amount_doesnotwork_either] as benchmark_best_index( topcount([Product].[Product].[Article], [amount], 10),1)
member [measures].[bm_top_amount_works] as benchmark_best_index2(1)
select { [measures].[amount],[measures].[bm_top_amount_doesnotwork], [measures].[bm_top_amount_doesnotwork_either], [measures].[bm_top_amount_works]} on 0
,article_list() on 1
from sales
I cannot get the calculated measure [bm_top_amount_doesnotwork] and [bm_top_amount_doesnotwork_either] to work.
My idea is to have 2 generic functions, with the 2nd one calling the first one. The end result is a benchmark value that can be used for charts, calculations and so on.
I see this is not possible form the above stated MDX. But is it possible? And if YES, how?
We've to check in detail what went wrong (issue) in the meantime you can force the type of the parameter so the MDX parser knows it is a set :
sum(order( {list} , [measures].[amount], desc).(i-1), [measures].[amount])

Named Set MDX Error

I'm having this error after creating a named set in SSAS to retrieve the last 10 weeks from the first day of current week. the expression I used is :
strtoset(
"LASTPERIODS(
10
,[AxeTemps].[Semaine].&["+Format(NOW()-WEEKDAY(NOW(),2),'yyyyMMdd')+"]")
My date hierarchy has the following members structure :
[AxeTemps].[Semaine].&[20000101].
I can't get this work, any idea ?
You have convert the a member first, then you can pass it to the LastPeriods():
LastPeriods(
10,
StrToMember("[AxeTemps].[Semaine].&[" + Format(NOW()-WEEKDAY(NOW(),2),'yyyyMMdd') + "]")
)

Displaying SSAS measure in thousands or millions

I have an Olap cube created using Microsoft SSAS. Inside I have a many-to-many relationship between source transaction currency and required "Reporting" currency. This is all functional, however to display a dynamic currency symbol I am using the "Currency" format string default and passing in a custom LCID based on the currency selected.
The problem with using the "Currency" format is the decimal places and large numbers. I am reporting millions of pounds/dollars and my CFO wants to see these numbers reported in thousands or millions. To control this I have read about using a special format string like #,, but this won't allow the currency symbol to be shown.
I had an idea to have a special dimension which would equate to 1, 1000, 1000000 and then create a calculated measure which divides by this (obviously defaulting to 1 and not aggregatable), but I have lots of measures.
Can anybody else advise on an alternative approach?
I would just set the FORMAT_STRING via a script assignment:
FORMAT_STRING(([Dim-Currency].[Currency Code].&[USD])) = "$#,,";
FORMAT_STRING(([Dim-Currency].[Currency Code].&[Euro])) = "€#,,";
You may use the SCOPE statement here:
Scope(AddCalculatedMembers([Measures].Members));
This = case
when [Measures].CurrentMember >= 1000000
then Cstr(Cint([Measures].CurrentMember / 1000000)) + " millions"
when [Measures].CurrentMember >= 1000
then Cstr(Cint([Measures].CurrentMember / 1000)) + " thousands"
else [Measures].CurrentMember
end;
End Scope;
Where Cint return int value and Cstr helps to join int value to text. I'm not sure if it's not too much. I've never used the "Currency" type, honestly.
I'm with #GregGalloway. In our cube-script it is implemented like this:
Scope
([Dim-Currency].[Currency Code].&[EUR]);
//EUR
FORMAT_STRING(This) = '€ #,##0.00';
End Scope;
Scope
([Dim-Currency].[Currency Code].&[GBP]);
FORMAT_STRING(This) = '£ #,##0.00';
End Scope;
We render via Pyramid front-end.

MDX " BETWEEN .. AND" CONDITION

I am using one MDX Equation as shown below.
SELECT
NON EMPTY { [Operator].[Total],[Operator].[Total] .Children } ON COLUMNS,
NON EMPTY { [Circle].[Total], [Circle].[Total] .Children } ON ROWS FROM
[16CircleWiseRoamingFailure5]
WHERE
( [Measures].[Count], [RoamingFlag].[INRoaming], [Date].[${yesterday}] , [SuccessFailureDetails].[FAILURE] )
here i am passing one function called "yesterday" which gives only yesterdays data.
Now i want to find values within an interval e.g. between month or between days. Can anyone tell me the syntax...?
In Analysis Services, you can use a range, using the ":" operator.
http://msdn.microsoft.com/en-us/library/ms146001.aspx
Don't know if it works in Pentaho