How could be solved problem below?
ERR: mondrian.olap.fun.MondrianEvaluationException: mondrian.olap.InvalidArgumentException: Mondrian Error:Invalid parameter. expression parameter of CDate function must be formatted correctly
My MDX request:
WITH
MEMBER
[Measures].[diff] as 'datediff("d",CDate([TimeDim.TimeHir].CurrentMember.Name),now())'
....
Have you tried other member properties:
WITH
MEMBER [Measures].[diff] as
'datediff("d",CDate([TimeDim.TimeHir].CurrentMember.MEMBER_VALUE),now())'
or
WITH
MEMBER [Measures].[diff] as
'datediff("d",CDate([TimeDim.TimeHir].CurrentMember.MEMBER_key),now())'
or
WITH
MEMBER [Measures].[diff] as
'datediff("d",CDate([TimeDim.TimeHir].CURRENTMEMBER.Properties('Key0', Typed)),now())'
Edit
This one works for me against AdvWks :
WITH
MEMBER [Measures].[Date_MEMBER_VALUE] as
[Date].[Calendar].CurrentMember.MEMBER_VALUE
MEMBER [Measures].[Diff_MEMBER_VALUE] as
datediff("D",CDate([Measures].[Date_MEMBER_VALUE]),now())
SELECT
{
[Measures].[Date_MEMBER_VALUE]
,[Measures].[Diff_MEMBER_VALUE]
}
ON 0,
tail([Date].[Calendar].[Date],12) ON 1
FROM [Adventure Works];
Edit
From here it looks like .MEMBER_VALUE does not exist in Mondrian so try using the above code with just .VALUE instead: http://mondrian.pentaho.com/documentation/mdx.php
You can use DateSerial function to convert your value to datetime format which is accepted by CDate
Related
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).
I have a parameter value 'SF - LYON' while trying to pass in where condition:
MEMBER [Measures].[ParameterCaption] AS [Organization].[Organization].CURRENTMEMBER.MEMBER_CAPTION
MEMBER [Measures].[Parametervalue] AS [Organization].[Organization].CurrentMember.UNIQUENAME
MEMBER [Measures].[ParameterLevel] AS [Organization].[Organization].CurrentMember.LEVEL.ORDINAL
SELECT non empty {[Measures].[ParameterCaption]
, [Measures].[ParameterValue]
, [Measures].[ParameterLevel] } ON COLUMNS
FROM [IRIS]
WHERE STRTomember('SF - LYON', CONSTRAINED) //#parameter=SF - LYON`
But I am getting this error:
Query (10, 1) The restrictions imposed by the CONSTRAINED flag in the STRTOMEMBER function were violated.
When I try it like this:
WHERE STRTomember('[SF - LYON]', CONSTRAINED) //#parameter=SF - LYON
it is working.
So my question is: How do I pass the square brackets [] through a parameter to get the desired result?
You can build up the parameter string with square brackets before passing it to the strToMember function
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])
This MDX function raise error :
with member measures.x as
(
[Date].[Date].[Date].&[20160101] : [Date].[Date].[Date].currentmember.value
,
[Measures].[current balance]
)
select measures.x on columns,
[Branch].[HeadOffice Branch].[Head Office Code] on rows
from MyCube
Error is :
The CURRENTMEMBER function expects a hierarchy expression for the 1 argument. A member expression was used.
But when I use
[Date].[Date].[Date].&[20160101] : [Date].[Date].[Date].&[20160131]
It works good
why?
This is valid mdx:
[Date].[Date].[Date].&[20160101] : [Date].[Date].currentmember
Although this is not:
WITH member measures.x AS
(
[Date].[Date].[Date].&[20160101] : [Date].[Date].currentmember
,
[Measures].[current balance]
)
It is not valid because round braces (...) signify a tuple but a tuple requires exact co-ordinates so the first argument cannot be a set.
You could add an aggregation such as SUM:
WITH member measures.x AS
SUM
(
[Date].[Date].[Date].&[20160101] : [Date].[Date].currentmember
,
[Measures].[current balance]
)
This is valid mdx but if you do not have [Date].[Date] in context i.e. in the WHERE or SELECT clause then all it is returning is the All member.
Why are you using [Date].[Date].currentmember ?
CURRENTMEMBER works on an attribute hierarchy (in your case [Date].[Date]). So [Date].[Date].CURRENTMEMBER will work.
Also you will need to take out the value selector, as your expression returns a set of dates (member : member returns a set of all the members between those two members).
We are facing issue while displying the amount in ssrs reports which makes use of mdx query.
For Example : this value is retured by mdx query 278.25 but when it is binded with ssrs it shows 27.825,00.
We are using culture de-DE(German) in report.
We have tried the following solutions but still the issue remains in SSRS report:
From mdx side We have tried FORMAT_STRING = "#0,00" function for displying numeric value.
From report side we have tried to use replace function to replace '.' with ',', but its not working fine.
Sample Query can be found below
WITH
MEMBER [Measures].[CumEGTKDAmount] AS sum({[Time].[Month].FIRSTCHILD: [Time].[Month].CurrentMember},[Measures].[EGTKD] * [Measures].[AvgStockPrice])
SELECT
{
[Measures].[CumEGTKDAmount]
} ON COLUMNS,
NON EMPTY {
topcount(
(
STRTOSET("[Dim Item].[ItemHierarchy].[Item No].&[00001133]")
)
,50,[Measures].[ReklaQuote])
} ON ROWS
FROM [QM]
Thanks
Try this:
=Replace(Format(Fields!YourFieldName.Value, "#,###0.00"),",",".")