How to add blank columns in MDX Query?
I have tried all possible options such as adding member and all, but when I am trying to cross join the new member, i get MDX errors. Please guide me through this.
Thanks
We need following MDX format and need blank columns in the MDX Query
My current MDX is
WITH
SET [PL_AsOfDate_XXX] AS
Distinct(
Hierarchize({
[AsOfDate].[ALL].[AllMember].[31-05-2013], [AsOfDate].[ALL].[AllMember].[30-05-2013]})
)
SET [PL_AsOfDate_XXX2] AS
Distinct(
Hierarchize({
[AsOfDate].[ALL].[AllMember].[31-05-2013]})
)
MEMBER [Book].[Books] AS
Aggregate({[Book].[ALL].[AllMember].[YYY], [Book].[ALL].[AllMember].[ZZZ]})
SELECT
NON EMPTY DrilldownLevel({[LBook].[ALL].[AllMember]}) ON ROWS,
NON EMPTY {Crossjoin({[Measures].[1D]}, [PL_AsOfDate_XXX]), Crossjoin({[Measures].[10D]}, [PL_AsOfDate_XXX2])} ON COLUMNS
FROM [Cube]
WHERE ([Book].[Books], [Type].[Type].[TOTAL])
With
Member Something as 1+1
member BlankColumn1 as null
member BlankColumn2 as null
member BlankColumn3 as null
Select (
{
Something,
BlankColumn1,
BlankColumn2,
BlankColumn3
})
on columns
from [UKM Trading]
Related
I have just started to work with OLAP Cubes. I have some questions about MDX queries. I have a query like:
WITH
MEMBER [Balance].[NegEXPENSE] AS '-[Balance].[Type].[EXPENSE]'
SET BalanceTypeSet AS {[Balance].[Type].[INCOME], [Balance].[NegEXPENSE]}
MEMBER [Balance].[TypeSum] AS AGGREGATE(BalanceTypeSet)
SELECT {Measures.[Sum]} ON COLUMNS,
{[Balance].[Type].[INCOME], [Balance].[Type].[EXPENSE], [Balance].[TypeSum]} ON ROWS
FROM [Balance Cube]
The result of this query like:
RESULT
This result doesn't have a name of the last row(TypeSum). How can I add a name for TypeSum?
Thanks.
You need to add calculated dimension member, try this:
WITH
MEMBER [Balance].[Type].[TypeSum] AS AGGREGATE(BalanceTypeSet)
SELECT {[Measures].[Sum]} ON COLUMNS,
{[Balance].[Type]} ON ROWS
FROM [Balance Cube]
I have an MDX query like this:
SELECT {[Gender].[Gender].AllMembers} ON COLUMNS,
{[Geography].[Country].AllMembers} ON ROWS FROM [myCube]
And I am trying to get this query as an olap4j object. I do this to set my dimension:
QueryDimension genderDim = myQuery.getDimension("GENDER");
But that produces just one column of "All Genders" and "All Geographys" respectively.
How do I get them broken down like the MDX query above?
If you switch to the MEMBERS function does that help?
SELECT
{[Gender].[Gender].MEMBERS} ON COLUMNS,
{[Geography].[Country].MEMBERS} ON ROWS
FROM [myCube];
I have an MDX query as follows:
WITH
MEMBER [MatCode] AS [Product].[Material]
SELECT
([MatCode]) on 0,
([Activity].[ActivityCode].[T-50051151]) ON 1
FROM
[Cube]
This returns a value such as:
MatCode
T-50051151 Null
Which tells me it is not joining the activity code to the description when I know they match up
How can I correct my MDX query to join activity code to material?
thanks
Why not try something like the following to look for areas of the cube with data? You'll can use the WHERE clause to slice by a specific measure in your cube.
SELECT
{[Activity].[ActivityCode].[T-50051151]} ON 0,
//NON EMPTY //<<include to hide nulls
{[Product].[Material].members} on 1
FROM
[Cube]
WHERE
([Measures].[someMeasure])
Your query returns the _ default _ value / cell for the tuple :
( [Activity].[ActivityCode].[T-50051151], [Product].[Material].defaultMember )
as well as the .defaultMember for every other dimension not mentionned in your query. There is nothing wrong with it.
I'm new to SSAS and need help with what would be equivalent to a where clause in SQL and I'm sure an easy answer for a MDX regular.
I have this pulling values for a multiple select parameter list in report builder but I need to filter out the contracts based on what project the user is currently viewing. Here is the query that is pulling all the values correctly.
WITH MEMBER [Measures].[ParameterCaption] AS [dimContracts].[ContractName].CURRENTMEMBER.MEMBER_CAPTION
MEMBER [Measures].[ParameterValue] AS [dimContracts].[Contract Name].CURRENTMEMBER.UNIQUENAME
SELECT {[Measures].[ParameterCaption],
[Measures].[ParameterValue]} ON COLUMNS,
[dimContracts].[Contract Name].Children ON ROWS
FROM [cubeProjectEntities]
I need to add what would be equivalant to:
WHERE dimContracts.[Project Id] = 1
I've added which produces the correct filtered set but from here I don't know how to use the report parameter to get it to work. Every time I test it just gives and empty dataset. I have the parameter just printing on the page so I know that it is set correctly.
WHERE [dimContracts].[Project Id].[1]
This does not work:
WHERE [dimContracts].[Project Id].[#ProjectId]
And then in Report builder I will pass a parameter to the query to replace the 1 for #projectId.
Thanks for any help!
WITH MEMBER [Measures].[ParameterCaption] AS [dimContracts].[ContractName].CURRENTMEMBER.MEMBER_CAPTION
MEMBER [Measures].[ParameterValue] AS [dimContracts].[Contract Name].CURRENTMEMBER.UNIQUENAME
SELECT {[Measures].[ParameterCaption],
[Measures].[ParameterValue]} ON COLUMNS,
[dimContracts].[Contract Name].Children ON ROWS
FROM [cubeProjectEntities]
Where (STRTOMEMBER(#projectid))
In MDX, the where clause is a slicer. Here's a good article about the differences between SQL and MDX.
Here's a link about using SSRS parameters with MDX queries. You'll actually want to pass the entire member name to the query rather than just the value (ex: [DimContracts].[Project ID].[1])
I am new with MDX, Can any one of you help me out for the below queries?
1) From the above result set how can I eliminate rows which are having the null values in the column1 & column3 using below query.
WITH
MEMBER TotalPatientCnt as '[Measures].[HealthPlanPatientCnt]'
MEMBER PrevalencePercent as '([Measures].[PatientCnt]*1.00/[Measures]. [TotalPatientCnt])*100'
SELECT
NON EMPTY {[DimCP_Population].[Dr Key].[Dr Key]}
ON rows,
{
[Measures].[PatientCnt] ,[Measures].[TotalPatientCnt]
,[Measures].[PrevalencePercent]
}
ON columns
FROM [StrategyCompanionDWCube]
WHERE
(
[DimAnchorDate].[Date Key].&[20121231],
[DimCP_PCP].[PCP Key].&[124],
[DimProduct].[Product Key].&[15],
[DimHealthPlan].[Health Plan Key].&[1]
)
;
2) I have 3 dimensions & 3 measures respectively
[DimCP_PCP], [DimProduct], [DimHealthPlan]
pcpCnt, productCnt, HelahtPlanPatientCnt
I would like to build same TotalPatientCnt member based on type of dimension with parameter value, Hope needs to write case statement but i could not write case statement please help us on the below examples.
WITH MEMBER TotalPatientCnt as
case
when [DimProduct].[Product Key].&[if getting anymember] then
'[Measures].[productCnt]'
when [DimHealthPlan].[Health Plan Key].&[if getting anymember] then
'[Measures].[HealthPlanPatientCnt]'
when [DimCP_PCP].[PCP Key].&[if getting anymember] then
'[Measures].[pcpCnt]'
If I get any parameter from [DimCP_PCP] for example [DimCP_PCP].[PCP Key].&[124] needs to show the TotalPatientCnt member like below
WITH MEMBER TotalPatientCnt as '[Measures].[pcpCnt]'
If I get any parameter from [DimHealthPlan] for example [DimHealthPlan].[Health Plan Key].&[1] needs to show the TotalPatientCnt member like below
WITH MEMBER TotalPatientCnt as '[Measures].[HealthPlanPatientCnt]'
If I get any parameter from [DimProduct] example [DimProduct].[Product Key].&[15] needs to show the TotalPatientCnt member like below
WITH MEMBER TotalPatientCnt as '[Measures].[productCnt]'
To answer your first question:
As NON EMPTY does not work for the rows here, as the second column is not empty for the records to exclude, you can use the rarely documented HAVING clause like this:
...
{[DimCP_Population].[Dr Key].[Dr Key]}
HAVING NOT IsEmpty([Measures].[PatientCnt])
AND NOT IsEmpty([Measures].[PrevalencePercent])
ON rows
...
SELECT
(
[DimAnchorDate].[Date Key].&[20121231],
[DimCP_PCP].[PCP Key].&[124],
[DimProduct].[Product Key].&[15],
[DimHealthPlan].[Health Plan Key].&[1],
[Measures].[PatientCnt],
[Measures].[TotalPatientCnt]
,[Measures].[PrevalencePercent]
) On 0,
NON EMPTY {[DimCP_Population].[Dr Key].[Dr Key]}
ON 1
FROM [StrategyCompanionDWCube]
OR
Understand the difference between NON-EMPTY vs Nonempty()
Here, you might get your answer and to do clear concept of NULL and EMPTY