Is it possible to use TopPercent or TopCount in CalculatedMembers in a MDX query?
Yes, there's basically no limitation in calculated member formula. But if your question is about having a calculated member of type 'set', then you should use a SET instead (WITH SET ...) or if you're using icCube a function (WITH FUNCTION...)
Cheers.
Related
Starting to learn MDX as one of the databases at work is based around a Cube
I have an SQL background so worked my way round understanding Tuples and Sets.
Where I am getting stuck is if I wanted to define multiple sets how can I do this via the WITH function. Following function works fine when I am defining one set with WITH function but surely there must be a way to define multiple sets.
Apologies if very basic function, I did try the search box but perhaps wasn't phrasing the request correctly.
Thanks in advance for any help
WITH SET
[MARKET] AS {[Location].&[Australia],[Location].[Singapore]},
[CALENDAR] AS {[Calendar].&[April,2018],[Calendar].&[May,2018]}
SELECT
{([Measures].[Money]),([Measures].[Target])} on 0,
{([CALENDAR],[MARKET],[Sales Department])}on 1
FROM AussieDatabase
You need to define each set explicitly, they can then be cross joined on rows
WITH
SET [MARKET] AS
{[Location].&[Australia]
,[Location].[Singapore]},
SET [CALENDAR] AS
{[Calendar].&[April,2018]
,[Calendar].&[May,2018]}
SELECT
{
[Measures].[Money]
,[Measures].[Target]
} on 0,
[CALENDAR] * [MARKET] on 1
FROM AussieDatabase;
(I guess it is not possible, but I might be overlooking something simple)
Is it possible to define a calculated member that does some calculation at the lowest level and have the result aggregated.
For example:
In the Builder, you define a member [measures].[calc] as [measures].[amount] X [measures].[count], and have the product only calculated at the lowest level and then its result aggregated over all dimensions.
A quick and easy answer, not yet
I'm trying to run the following MDX query (I'm newbie in the matter):
WITH MEMBER [Measures].[Not Null SIGNEDDATA] AS IIF( IsEmpty( [Measures].[SIGNEDDATA] ), 0, [Measures].[SIGNEDDATA] )
SELECT
{[Measures].[Not Null SIGNEDDATA]} ON COLUMNS,
{[Cuenta].[818000_001],[Cuenta].[818000_G02]} ON ROWS
FROM [Notas_SIC]
WHERE ([Auditoria].[AUD_NA],[Concepto].[CONCEPTO_NA],[Entidad].[CCB],
[Indicador].[INDICADOR_NA],[Interco].[I_NONE],[Moneda].[COP],
[Tiempo].[2010.01],[Version].[VERSION_NA])
Where 818000_001 is a base member of my 'Cuenta' dimension, and 818000_G02 is a node or aggregation. I receive the following message:
"Two sets specified in the function have different dimensionality"
What am I doing wrong? If I put the query with only base members (many) or only differents aggregations, the result is ok as expected.
Thanks in advance!
By using commas in your WHERE clause, you are trying to create a set out of members from different dimensions. You should use asterisks to make a CROSSJOIN instead.
So replace this:
WHERE ([Auditoria].[AUD_NA],[Concepto].[CONCEPTO_NA],[Entidad].[CCB],
[Indicador].[INDICADOR_NA],[Interco].[I_NONE],[Moneda].[COP],
[Tiempo].[2010.01],[Version].[VERSION_NA])
With this:
WHERE ({[Auditoria].[AUD_NA],[Concepto].[CONCEPTO_NA],[Entidad].[CCB]} *
{[Indicador].[INDICADOR_NA],[Interco].[I_NONE],[Moneda].[COP]} *
{[Tiempo].[2010.01],[Version].[VERSION_NA]})
I added curly braces though I'm not sure if they're absolutely required.
This is maybe your problem:
{[Cuenta].[818000_001],[Cuenta].[818000_G02]} ON ROWS
You have put them as a set but you can only make a set out of members with the same dimensionality. From your description it sounds like [Cuenta].[818000_G02] is being classed as a different hierarchy which is unexpected.
Is [Cuenta].[818000_G02] created using the Aggregate function? Can you swap to using the Sum function? Does the script then work?
(not a great answer - just more questions?)
{[Cuenta].[818000_001],[Cuenta].[818000_G02]}
Your problem probably lies in the above statement. As is clear, they could be from different hierarchies(which is not clear from your example and I come to that below).
Try replacing the above with
{[Cuenta].[Hierarchy1].[818000_001]} * {[Cuenta].[Hierarchy2].[818000_G02]}
where Hierarchy1 and Hierarchy2 are the hierarchies to which these members belong. (If you are not sure, just try {[Cuenta].[818000_001]} * {[Cuenta].[818000_G02]}). I am assuming that the second aggregate members may be built on a different hierarchy and thus the engine is throwing an error.
It is generally a good habit to always use the fully qualified member name because then the SSAS engine has to spend less time in searching for the member.
How to resolve the below expression:
sum({<Category={'Internal Ops SLA'}>}(RangeSum(Above(sum(InternalOpsSLA),0,12))/TargetOpsSLA)*Weight)
It is giving the error in expression, because of the double sum.
The multiplier Weight value is selected as per the category in the set expression modifier. Is there any other way, apart from variable with ONLY as I need to sum the final results, for the above expression ?
I know this post is pretty old. Responding to it, thinking that it might help a few.
I faced a similar problem in qlikview, while trying to compute Sum of Averages. With an error message:
(Error in expression: Nest Aggregation not allowed)
I realized that one work around for this is to use, aggregate functions. Instead of grouping them like:
sum(avg(<Dimension_Name>condition))
I grouped them as:
Sum(Aggr(Avg(condition), Dimension_Name))
and this worked well for me.
So for your problem, I would try something like this:
sum(aggr(if(Category = {'Internal Ops SLA'},(RangeSum(Above(sum(InternalOpsSLA),0,12))/TargetOpsSLA)*Weight),'Dimension Name'))
What is the simplest MDX request?
I want to test whether my MDX endpoint answers correctly to a very simple request.
In SQL, I would say SELECT 1;
I guess the simplest MDX request would be : SELECT FROM cubeName
This query will display your first measure against the top level of the first dimension it finds. All you need to specify is the name of your cube. It will return one number.
SELECT {Dimensions(0).defaultMember} ON ROWS,
{[Measures].defaultMember} ON COLUMNS
FROM [NameOfCube]
I'm not sure that you can bring back constants in an MDX query - you've piqued my interest. I would just fire off a query against a base measure in your cube, if you don't specify any additional axis you'll get a single value result set.
SELECT [MeasureGroup].[Measure]
FROM [Cube]
Pretty basic - here's MS guide to the basic syntax for an MDX statement.
WITH MEMBER Test AS 1
SELECT Test ON COLUMNS FROM [Cube]
Constants all the way down.
You could try MDSchema rowsets. Use select * from $system.Discover_Schema_Rowsets to find ones to choose among. I'm partial to this one:
select TOP 0 [CATALOG_NAME]
from $system.DBSCHEMA_CATALOGS
It returns over 1KB, but that's small for the XMLA endpoint.
However, I like this better; create a session-scoped calculated member (or set), which disappears after your command is executed. The response is very short:
PS C:> Invoke-ASCmd -Query "CREATE MEMBER [mycube].x AS 1" -Server myserver -Database mydatabase
<return xmlns="urn:schemas-microsoft-com:xml-analysis"><root xmlns="urn:schemas-microsoft-com:xml-analysis:empty"></root></return>