My MDX request gives to me this result:
For my entities, I've multiple years for one value, I need just get the first year for the entity (and others dimensions). I've tried to use the function .FirstChild in the year dimension this return only value with the year '2014' (first year in my dimension). The function .Item() returns only empty values:
SELECT
NON EMPTY
{[Measures].[Value]} ON COLUMNS
,NON EMPTY
{
[EntiteFederal].[EntiteCode].[EntiteCode].ALLMEMBERS*
[T].[Year].[Year].ALLMEMBERS*
[T].[YearDate].[YearDate].ALLMEMBERS
}
DIMENSION PROPERTIES
MEMBER_CAPTION
,MEMBER_UNIQUE_NAME
ON ROWS
FROM [Mycube];
Hopefully this is working - tricky for me to test:
WITH
SET [EntYr] AS
Generate
(
[EntiteFederal].[EntiteCode].[EntiteCode].MEMBERS AS X
,
X.CurrentMember
*
Head
(
NonEmpty
(
[T].[Year].[Year].ALLMEMBERS * [T].[YearDate].[YearDate].ALLMEMBERS
,X.CurrentMember
)
)
)
SELECT
NON EMPTY
[Measures].[Value] ON COLUMNS
,NON EMPTY
[EntYr] ON ROWS
FROM [Mycube];
Related
WITH
MEMBER CostDifference AS
Sum([Measures].[ExtendedCost]) - [Measures].[ExtendedCost]
SELECT
NON EMPTY
{
[Measures].[ExtendedCost]
,CostDifference
} ON COLUMNS
,NON EMPTY
{[Parts].[ItemDesc].MEMBERS, [Dim Date].[DateUK].MEMBERS} ON ROWS
FROM [Cube]
I'm trying to subtract a measures across different dimensions i.e. for 2 date snapshots (31/1/2010 and 28/2/2010) for all the products in DimParts
if I remove this piece of code from equation then all I get is zeros
[Dim Date].[DateUK].MEMBERS
If I use a cross join to add more than one dim even then the cost difference is zero
e.g. ,NON EMPTY
CrossJoin
(
[Parts].[ItemDesc].MEMBERS
,{[Dim Date].[DateUK]}
) ON ROWS
I'm using SQl Server 2008R2
What am I missing here.
This Sum([Measures].[ExtendedCost]) - [Measures].[ExtendedCost]
Will resolve to this
[Measures].[ExtendedCost] - [Measures].[ExtendedCost]
Which is always 0
If this Sum([Measures].[ExtendedCost]) needs to be across a complete set then you need to include that set:
Sum(
[Dim Date].[DateUK].MEMBERS
,[Measures].[ExtendedCost]
)
I am using a BI tool that auto-generates MDX code for an Essbase data source. I am running two queries that should bring back the same numbers, but I get different numbers.
The first query brings back results by month for 12 months of the year and produces incorrect results:
SELECT
NON EMPTY
{
[Jan]
,[Feb]
,[Mar]
,[Apr]
,[May]
,[Jun]
,[Jul]
,[Aug]
,[Sep]
,[Oct]
,[Nov]
,[Dec]
}
DIMENSION PROPERTIES
[MEMBER_UNIQUE_NAME]
,[MEMBER_CAPTION]
,[GEN_NUMBER]
,[LEVEL_NUMBER]
ON COLUMNS
,NON EMPTY
Descendants
(
[ABOVE]
,[ABOVE].Level
,AFTER
)
DIMENSION PROPERTIES
[MEMBER_UNIQUE_NAME]
,[MEMBER_CAPTION]
,[GEN_NUMBER]
,[LEVEL_NUMBER]
ON ROWS
FROM [F_IntPrf].[F_IntPrf]
WHERE
(
[ALL_TERRITORY]
,[ALL_PS_BUS_AFF]
,[ALL_PS_BUS]
,[Input Currency]
,[MayFC]
,[FY17]
,[Forecast]
,[USDRep]
);
The second query shows the results for January only, and produces the correct results :
SELECT
NON EMPTY
Descendants
(
[ABOVE]
,[ABOVE].Level
,AFTER
)
DIMENSION PROPERTIES
[MEMBER_UNIQUE_NAME]
,[MEMBER_CAPTION]
,[GEN_NUMBER]
,[LEVEL_NUMBER]
ON COLUMNS
FROM [F_IntPrf].[F_IntPrf]
WHERE
(
[Jan]
,[ALL_TERRITORY]
,[ALL_PS_BUS_AFF]
,[ALL_PS_BUS]
,[Input Currency]
,[MayFC]
,[FY17]
,[Forecast]
,[USDRep]
);
What am I doing wrong in the first query ?
Thank you!
To focus in on the problem I would start by comparing two very simple queries such as these two:
SELECT
NON EMPTY
{
[Jan]
}
ON COLUMNS
,NON EMPTY
Descendants
(
[ABOVE]
,[ABOVE].Level
,AFTER
)
ON ROWS
FROM [F_IntPrf].[F_IntPrf]
WHERE
(
[ALL_TERRITORY]
);
versus this...
SELECT
NON EMPTY
Descendants
(
[ABOVE]
,[ABOVE].Level
,AFTER
)
ON COLUMNS
FROM [F_IntPrf].[F_IntPrf]
WHERE
(
[Jan]
,[ALL_TERRITORY]
);
Do they match? If they do then slowly add in the other dimensions until they don't match and then you know where the problem is
UPDATE: the resolution was to do a process full at the database level instead of at the partition level.
I am trying to understand the behavior I am observing with a query a Tabular model. I partition by quarter, so when I built a new "current quarter" partition at the start of this quarter, the partition that used to contain 2016-Q4 was overwritten with 2017-Q1. Then when I ran my MDX query against the Tabular model filtering on the date dimension for 2016-Q4, instead of returning nothing like I would have expected, it returned data from the oldest partition 2014-Q1. It is like instead of returning no data, it decides to return the "first record" for that dimension (in this case all dates where 07/01/2014). Every other dimension I was filtering on still performed as expected.
Does anybody have any ideas as to why it behaves this way? FYI, I have tried restructuring my MDX statement a couple different ways:
SELECT
NON EMPTY { [Measures].[Measure1]} ON COLUMNS,
NON EMPTY { ([Dimension].[Dimension1])} DIMENSION PROPERTIES member_caption, member_unique_name ON ROWS
FROM [Model] WHERE ([Dimension].[Dimension2].&[Value], [DateDimension].[DateDimension].&[Value1] : [DateDimension].[DateDimension].&[Value2])
AND
SELECT
NON EMPTY { [Measures].[Measure1]} ON COLUMNS,
NON EMPTY { ( except([Dimension].[Dimension1].members,[Dimension].[Dimension1].[all]))} DIMENSION PROPERTIES member_caption, member_unique_name ON ROWS
FROM ( SELECT ( [Dimension].[Dimension1].&[Value] ) ON COLUMNS
FROM ( SELECT ( [Dimension].[Dimension2].&[Value] ) ON COLUMNS
FROM ( SELECT ( [DateDimension].[DateDimension].&[Value1] : [DateDimension].[DateDimension].&[Value2] ) ON COLUMNS
FROM [Model])))
Edit: added example of actual MDX
SELECT
NON EMPTY { [Measures].[ConvertedNetRevenue],
[Measures].[LoadConvertedNetRevenue],
[Measures].[OrderConvertedNetRevenue],
[Measures].[TotalOrderBrokerageCount],
[Measures].[TotalLoadBrokerageCount]
} ON COLUMNS,
NON EMPTY {
(
except([BrokerageQuery].[KeyBranch].members,[BrokerageQuery].[KeyBranch].[all]),
except([BrokerageQuery].[LoadNumber].members,[BrokerageQuery].[LoadNumber].[all]),
except([BrokerageQuery].[CustomerOrderNumber].members,[BrokerageQuery].[CustomerOrderNumber].[all]),
except([BrokerageQuery].[BranchName].members,[BrokerageQuery].[BranchName].[all]),
except([BrokerageQuery].[BranchCode].members,[BrokerageQuery].[BranchCode].[all]),
except([BrokerageQuery].[BranchRoleDescription].members,[BrokerageQuery].[BranchRoleDescription].[all]),
except([BrokerageQuery].[ModeDescription].members,[BrokerageQuery].[ModeDescription].[all]),
except([BrokerageQuery].[ServiceTypeDescription].members,[BrokerageQuery].[ServiceTypeDescription].[all]),
except([BrokerageQuery].[SystemDisplayName].members,[BrokerageQuery].[SystemDisplayName].[all]),
except([BrokerageQuery].[IsPartialFinLock].members,[BrokerageQuery].[IsPartialFinLock].[all]),
except([BrokerageQuery].[KeyDate_Financial].members,[BrokerageQuery].[KeyDate_Financial].[all])
)
} DIMENSION PROPERTIES member_caption, member_unique_name ON ROWS
FROM ( SELECT
(
{
[dimCurrency].[CurrencyCode].&[USD]
}
) ON COLUMNS
FROM ( SELECT
(
{
{
[BrokerageQuery].[KeyBranch].[10279]
}
}
) ON COLUMNS
FROM ( SELECT
(
[BrokerageQuery].[KeyDate_Financial].&[20161106] :
[BrokerageQuery].[KeyDate_Financial].&[20161106]
) ON COLUMNS
FROM [Brokerage])))
Instead of processing our partitions individually (at the beginning of each quarter when re-partitioning occurs), we need to do a database-level process full.
I need to filter the dimension [Line] just for a specific [Year].Member.
For example,
[Time].[2004] to show results ([Product].[Line].[Classic Cars] and [Product].[Line].[Ships]) - excude the rest of [Product].[Line] members for [Time].[2004] but do not exclude [Product].[Line] members for the other [Time].Members.
I need a code compatible with Mondrian.
Any suggestion?
SELECT
NON EMPTY {[Measures].[Sales]} ON COLUMNS,
NON EMPTY NonEmptyCrossJoin([Time].[Years].Members, [Product].[Line].Members) ON ROWS
FROM
[SteelWheelsSales]
Something like this should work:
SELECT
NON EMPTY
{[Measures].[Sales]} ON COLUMNS
,NON EMPTY
{
(
[Time].[2004]
,{
[Product].[Line].[Classic Cars]
,[Product].[Line].[Ships]
}
)
,NonEmptyCrossJoin
(
Except
(
[Time].[Years].MEMBERS
,[Time].[2004]
)
,[Product].[Line].MEMBERS
)
} ON ROWS
FROM [SteelWheelsSales];
I am working to optimize the query time. But in my cases, case 1 and case 2 are returning the same result. case 1 should return result for a particular data range i.e. [time].[2015].[5].[10] : [time].[2015].[6].[9] instead it is returning only for [time].[2015].[6].[9] as the result of case 2. case 1 returns the correct result i.e. data for the range but only if you remove the non empty clause. removing the non empty clause means it will search the entire data sets which is again taking lots of time. again case 3 returns correct result but operation is even more time then the first approach. Anybody facing such issue or can guide me to for the problem.
CASE 1
WITH
MEMBER [Measures].[abc_type] AS
[abc].CurrentMember.Properties("abc_type")
MEMBER [Measures].[abc_desc] AS
[abc].CurrentMember.Properties("abc_desc")
MEMBER [Measures].[abc_class] AS
[abc].CurrentMember.Properties("abc_class")
SELECT
NON EMPTY
{
[Measures].[abc_type]
,[Measures].[abc_desc]
,[Measures].[abc_class]
} ON COLUMNS
,NON EMPTY
Filter
(
{[abc].[abc_id].MEMBERS}
,St_contains
(
[district].[district_id].[1].Properties("the_geom")
,[abc].CurrentMember.Properties("the_geom")
)
) ON ROWS
FROM [analytics_cube]
WHERE
[time].[2015].[5].[10] : [time].[2015].[6].[9];
CASE 2
WITH
MEMBER [Measures].[abc_type] AS
[abc].CurrentMember.Properties("abc_type")
MEMBER [Measures].[abc_desc] AS
[abc].CurrentMember.Properties("abc_desc")
MEMBER [Measures].[abc_class] AS
[abc].CurrentMember.Properties("abc_class")
SELECT
NON EMPTY
{
[Measures].[abc_type]
,[Measures].[abc_desc]
,[Measures].[abc_class]
} ON COLUMNS
,NON EMPTY
Filter
(
{[abc].[abc_id].MEMBERS}
,St_contains
(
[district].[district_id].[1].Properties("the_geom")
,[abc].CurrentMember.Properties("the_geom")
)
) ON ROWS
FROM [analytics_cube]
WHERE
[time].[2015].[6].[9];
CASE 3
WITH
MEMBER [Measures].[abc_type] AS
[abc].CurrentMember.Properties("abc_type")
MEMBER [Measures].[abc_desc] AS
[abc].CurrentMember.Properties("abc_desc")
MEMBER [Measures].[abc_class] AS
[abc].CurrentMember.Properties("abc_class")
MEMBER [time].[newtime] AS
Aggregate([time].[2015].[5].[10] : [time].[2015].[6].[9])
SELECT
NON EMPTY
{
[Measures].[abc_type]
,[Measures].[abc_desc]
,[Measures].[abc_class]
} ON COLUMNS
,NON EMPTY
Filter
(
{[abc].[abc_id].MEMBERS}
,St_contains
(
[district].[district_id].[1].Properties("the_geom")
,[abc].CurrentMember.Properties("the_geom")
)
) ON ROWS
FROM [analytics_cube]
WHERE
[time].[newtime];
Ranges of time are always evaluated by Mondrian as a full level scan. It will load all of the members of the given time level and will start iterating over the members until it finds the first bound. It will then create a sublist up until the last member of the range.
There is an enhancement request filed to turn ranges into SQL predicates here.
If you get a chance to test the prototype code, let us know how it works for you