Here is my MDX query below:
SELECT
{
[Measures].[Amt Exrate]
,[Measures].[Comm Exrate]
} ON COLUMNS
,NonEmpty([AccSetting].[User N].[User N] * [Cur Log].[Cur Log ID].Children) ON ROWS
FROM [report]
WHERE
[AccSetting].[Ag ID].&[113];
http://i.stack.imgur.com/0yDHg.png
UserID =113 is a hierarchies and a want to get the userN of it
I want to return exactly UserName of UserID =113 on Rows. but I'm not sure how to do it.
If you just want the name and nothing else then this should do it:
SELECT
{} ON COLUMNS
,[AccSetting].[User N].[User N] ON ROWS
FROM [report]
WHERE
[AccSetting].[Ag ID].&[113];
If you want to turn the name into a measure then something like the following, with a custom measure should help:
WITH
MEMBER [Measures].[userName] AS
[AccSetting].[User N].CurrentMember.Member_Caption
SELECT
{} ON 0
,{
[Measures].[userName]
,[Measures].[Amt Exrate]
,[Measures].[Comm Exrate]
} ON 1
FROM [report]
WHERE
[AccSetting].[Ag ID].&[113];
To return the columns you mentioned in comment this should work:
SELECT
NON EMPTY
{
[Measures].[Amt Exrate]
,[Measures].[Comm Exrate]
} ON COLUMNS
,NON EMPTY
[AccSetting].[User N].[User N].MEMBERS
* [Cur Log].[Cur Log ID].MEMBERS
ON ROWS
FROM [report]
WHERE
[AccSetting].[Ag ID].&[113];
EDIT
Answer in this article:
Get hierarchies valuesName mdx
Try having this way:
with dynamic set UserN as
NonEmpty(
[AccSetting].[User N].[User N].members * [Cur Log].[Cur Log ID].Children
,
[AccSetting].[Ag ID].currentmember
*
{
[Measures].[Amt Exrate],
[Measures].[Comm Exrate]
}
)
SELECT
{
[Measures].[Amt Exrate]
,[Measures].[Comm Exrate]
} ON COLUMNS
,UserN ON ROWS
FROM [report]
WHERE
[AccSetting].[Ag ID].&[113];
Related
I need two join two queries, I tried with members but it didn't work. I am new to MDX, please let me know if there a way of doing this. Error is due to list in the calculated member.
SELECT NON EMPTY { [RR TYPE].[Item].[Item].ALLMEMBERS * [Measures].[Unit Value] } ON COLUMNS,
NON EMPTY { ([FFS].[FFSCD].[FFSCD].ALLMEMBERS) } ON ROWS
FROM [GLCube]
WHERE ( [Location].[Site Name].&[Sandbox]
, [LT DT].[DATE HIERARCHY].[YEAR].&[2010]
,-{ [Ledger].[ID].&[A1],[Ledger].[ID].&[A2] ,[Ledger].[ID].&[A3]} )
SELECT NON EMPTY { [RT TYPE].[Item].[Item].ALLMEMBERS * [Measures].[Price Value] } ON COLUMNS,
NON EMPTY { ([FFS].[FFSCD].[FFSCD].ALLMEMBERS) } ON ROWS
FROM (SELECT [CCTYPE].[Desc].&[FCD] ON COLUMNS
FROM [GLCube])
WHERE ( [Location].[Site Name].&[Sandbox]
, [LT DT].[DATE HIERARCHY].[YEAR].&[2010])
Combined query
WITH MEMBER [Measures].[Unit Value]] AS
(-{[Ledger].[ID].&[A1],[Ledger].[ID].&[A2] ,[Ledger].[ID].&[A3]},[Measures].[Unit Value])
MEMBER [Measures].[Price Value] AS
( [CCTYPE].[Desc].&[FCD],[Measures].[Price Value] )
SELECT NON EMPTY {[Measures].[Unit Value],[Measures].[Price Value]} ON COLUMNS,
NON EMPTY { ([FFS].[FFSCD].[FFSCD].ALLMEMBERS} ON ROWS
FROM [GLCube]
WHERE ( [Location].[Site Name].&[Sandbox]
, [LT DT].[DATE HIERARCHY].[YEAR].&[2010])
Expected Output
WITH
MEMBER [Measures].[Filtered Unit Value] as
Aggregate(
-{ [Ledger].[ID].&[A1],[Ledger].[ID].&[A2] ,[Ledger].[ID].&[A3]},
[Measures].[Unit Value]
)
SELECT NON EMPTY
{
[RR TYPE].[Item].[Item].ALLMEMBERS
* {[RT TYPE].[Item].[All]}
* { [CCTYPE].[Desc].[All]}
* [Measures].[Filtered Unit Value]
}
+
{
{[RR TYPE].[Item].[All]}
* [RT TYPE].[Item].[Item].ALLMEMBERS
* { [CCTYPE].[Desc].&[FCD]}
* [Measures].[Price Value]
}
ON COLUMNS,
NON EMPTY { ([FFS].[FFSCD].[FFSCD].ALLMEMBERS) } ON ROWS
FROM [GLCube]
WHERE ( [Location].[Site Name].&[Sandbox]
, [LT DT].[DATE HIERARCHY].[YEAR].&[2010]
)
I have below select statement which I want to convert into cube members and calculate the sum.
SELECT NON EMPTY { [Measures].[volume] } ON COLUMNS, NON EMPTY { ([par_Account].[Account].[Account].ALLMEMBERS * [Product].[Hierarchy].[Local product var].ALLMEMBERS ) } ON ROWS FROM ( SELECT ( { [Product].[Hierarchy].[local product Group].&[-33554010354150679].&[-952789350662854159].&[8639428195894987853] } ) ON COLUMNS FROM ( SELECT ( { [Time].[Financial Period].&[-8540082585673218205] } ) ON COLUMNS FROM ( SELECT ( { [Market].[Market].&[-3381499019102906042] } ) ON COLUMNS FROM [cube]))) WHERE ( [Market].[Market].&[-3381499019102906042], [Time].[Financial Period].&[-8540082585673218205] )
Please help me with this.
I guess this is what you are looking for. However its always nice to explain what your problem is, or perhaps provide screenshot.
SELECT
NON EMPTY { [Measures].[volume] } ON COLUMNS,
NON EMPTY {
(
[Market].[Market].&[-3381499019102906042] *
[Time].[Financial Period].&[-8540082585673218205] *
{ [Product].[Hierarchy].[local product Group].&[-33554010354150679].&[-952789350662854159].&[8639428195894987853] } *
[par_Account].[Account].[Account].ALLMEMBERS *
[Product].[Hierarchy].[Local product var].ALLMEMBERS
)
} ON ROWS
from [cube]
I have a problem with MDX querying.
I have one measure WEIGHT and two dimensions DESTINATION and SOURCE with the same attributes: NAME and TYPE.
I want to return:
SUM of WEIGHT
where
DESTINATION.TYPE="A"
**OR**
SOURCE.TYPE="B"
**AND**
(DESTINATION.TYPE **<>** SOURCE.TYPE)
If try this:
SELECT NON EMPTY {
[Measures].[Weight]
}
ON COLUMNS,
NON EMPTY {
([Source].[Name].[Name].ALLMEMBERS * [Destination].[Name].[Name].ALLMEMBERS )
}
ON ROWS
FROM
( SELECT ( { [Source].[Type].&[A] } ) ON COLUMNS FROM ( SELECT ( { [Destination].[Type].&[B] } )
ON COLUMNS FROM [CUBE])) WHERE ( [Destination].[Type].&[B], [Source].[Type].&[A] )
But it doesn't work.
In SQL it look like
Select source.name, destination.name, sum(weight) from cube
where
(source.type = "A" or destination.type = "b")
and
(source.type <> destination.type)
group by source.name, destination.name, source.type, destination.type
Your From section is a bit messy. Try the following:
SELECT
NON EMPTY { [Measures].[Weight] } ON COLUMNS,
NON EMPTY { [Source].[Name].[Name].ALLMEMBERS * [Destination].[Name].[Name].ALLMEMBERS } ON ROWS
FROM [CUBE]
WHERE ( {[Destination].[Type].&[B]} * {[Source].[Type].[All]} + {[Destination].[Type].[All]} * {[Source].[Type].&[A]} )
I have an MDX query like;
with
set [IcPiyasaCC] as
{
[DimCostCenterView].[CostCenterKey].&[S_EDT],
[DimCostCenterView].[CostCenterKey].&[S_END.MRG],
[DimCostCenterView].[CostCenterKey].&[S_GM_YRD],
[DimCostCenterView].[CostCenterKey].&[S_PER.RAF],
[DimCostCenterView].[CostCenterKey].&[S_ULUSAL],
[DimCostCenterView].[CostCenterKey].&[S_PAS_MARG]
}
member [DimCostCenterView].[CostCenterKey].[IcPiyasa] as
aggregate([IcPiyasaCC])
SELECT
NON EMPTY
{
[Measures].[Fiili_TutarTonaj]
} ON COLUMNS,
NON EMPTY
{
(
[DimCostCenterView].[CostCenterKey].[IcPiyasa]
--*[DimCostCenterView].[CostCenterKey].[CostCenterKey].ALLMEMBERS
)
}
ON ROWS
and I can get desired output like;
- Fiili_TutarTonaj
IcPiyasa 6
But when I try to cross join with [DimCostCenterView].[CostCenterKey].[CostCenterKey].ALLMEMBERS which is on same hierarchy, to get if any related "CostCenterKey"s , I get "CostCenterKey hierarchy is used more than once in the Crossjoin function." error message. How can I crossjoin them to get result like;
- - Fiili_TutarTonaj
IcPiyasa S_EDT 1
IcPiyasa S_END.MRG 2
IcPiyasa S_ULUSAL 3
Thanks.
You can host the new aggregated member in a different hierarchy. The cross-join will then be possible:
WITH
SET [IcPiyasaCC] AS
{
[DimCostCenterView].[CostCenterKey].&[S_EDT],
[DimCostCenterView].[CostCenterKey].&[S_END.MRG],
[DimCostCenterView].[CostCenterKey].&[S_GM_YRD],
[DimCostCenterView].[CostCenterKey].&[S_PER.RAF],
[DimCostCenterView].[CostCenterKey].&[S_ULUSAL],
[DimCostCenterView].[CostCenterKey].&[S_PAS_MARG]
}
MEMBER [Geography].[Geography].[All].[IcPiyasa] AS
AGGREGATE(
[IcPiyasaCC],
([Geography].[Geography].[All])
)
SELECT
NON EMPTY
[Measures].[Fiili_TutarTonaj] ON 0,
NON EMPTY
[Geography].[Geography].[All].[IcPiyasa]
*[DimCostCenterView].[CostCenterKey].[CostCenterKey].ALLMEMBERS
ON 1
...
...
Or this:
WITH
SET [IcPiyasaCC] AS
{
[DimCostCenterView].[CostCenterKey].&[S_EDT],
[DimCostCenterView].[CostCenterKey].&[S_END.MRG],
[DimCostCenterView].[CostCenterKey].&[S_GM_YRD],
[DimCostCenterView].[CostCenterKey].&[S_PER.RAF],
[DimCostCenterView].[CostCenterKey].&[S_ULUSAL],
[DimCostCenterView].[CostCenterKey].&[S_PAS_MARG]
}
MEMBER [Measures].[ForceName] AS 'IcPiyasaCC'
MEMBER [Geography].[Geography].[All].[IcPiyasa] AS
(
[Geography].[Geography].[All]
,[Measures].[ForceName]
)
SELECT
NON EMPTY
[Measures].[Fiili_TutarTonaj] ON 0,
NON EMPTY
[Geography].[Geography].[All].[IcPiyasa]
*[DimCostCenterView].[CostCenterKey].[CostCenterKey].ALLMEMBERS
ON 1
I am attempting to implement paging to large datasets in MDX (SSAS).
I have the following to retrieve paged data which works fine:
SELECT
{
[Measures].[Mesasure1],
[Measures].[Measure2]
} ON COLUMNS,
SUBSET
(
ORDER
(
{
(
[Item].[Category].ALLMEMBERS
)
}, NULL, BASC
), 10, 50 --10 = start index, 50 = returned roes
)
ON ROWS
FROM ( SELECT ( { [Time].[Date].&[2012-04-15T00:00:00]:[Time].[Date].&[2012-04-20T00:00:00] } ) ON COLUMNS
FROM [DataMartPerformance]
))
However I cannot for the life of me find anywhere on the internet that helps explain how to get the total rows available. Do I do it in a seperate query? If so how?
Or can I wrap it into this one query somehow?
Similar to how you'd do TSQL paging, you'll need to run another query to count the total elements. You may have to tinker with this depending on how you've done your original query, but I use something like:
WITH
MEMBER [Measures].[ElementCount] AS
{
NONEMPTY
(
{
[Item].[Category].ALLMEMBERS *
{ [Time].[Date].&[2012-04-15T00:00:00]:[Time].[Date].&[2012-04-20T00:00:00] }
},
{
[Measures].[Mesasure1],
[Measures].[Measure2]
}
)
}.COUNT
SELECT
{
[Measures].[ElementCount]
}
ON COLUMNS
FROM
[DataMartPerformance]
For filtering, you can do dimension filters by using an exists against your dimension attributes:
WITH
MEMBER [Measures].[ElementCount] AS
{
NONEMPTY
(
EXISTS
(
{
[Item].[Category].ALLMEMBERS *
{ [Time].[Date].&[2012-04-15T00:00:00]:[Time].[Date].&[2012-04-20T00:00:00] }
},
{
[Dimension].[Attribute].[FilterByThisAttribute]
}
),
{
[Measures].[Mesasure1],
[Measures].[Measure2]
}
)
}.COUNT
SELECT
{
[Measures].[ElementCount]
}
ON COLUMNS
FROM
[DataMartPerformance]
I haven't got to writing the measure value filters yet, I need to do that next for my own MDX paging constructor...
Please try this:
WITH
SET MySet As
(
NONEMPTY (
[AU Time Sale Hour].[Hour Key].[Hour Key]
* [Dim Country].[Country Key].[Country Key]
)
)
Member [Measures] .cnt AS MySet.Count
select [Measures] .cnt on Columns
from [Me Stats DW Fact Sales]
where (
{[Dim Visa].[Visa Key].&[2067],[Dim Visa].[Visa Key].&[2068] },
[AU Time Sale Date].[Date].&[20091120]:[AU Time Sale Date].[Date].&[20091125]
)