2016-02-12 36 views
0

我可以爲此示例實現哪些mdx查詢邏輯,以獲得hrid = 1的結果集中的兩行,其中1/1/16爲最短日期(開始)行someattribut在值爲'A' 和1/15/16作爲第二行的最小日期(開始)的列上出現,其中someattribute的值爲'B',measure.whatevers將其聚合到與該維度對應的任何數據行。如何在mdx查詢中獲取列的最小或最大日期

我試着去只是看2016年1月

一切我用盡我似乎得到的1/1/1900分鐘日期值或兩列有2016年1月1日值或我得到的錯誤,因爲我不能想辦法。

enter image description here

我的繼承人MDX示例:

WITH MEMBER [Measures].[Start] as 
    (
-- min date that the combination of someattribute and hrid have certain 
-- value withing the range of the where clause restriction of january 2016 

SELECT { 
[Measures].[Start] 
, [Measures].[Whatevers] 
} ON COLUMNS 
, NON EMPTY { 
[Agent].[HRID].children 
* [Agent].[someAtribute].Members 
} ON ROWS 
FROM [RADM_REPORTING] 
WHERE ( 
    [Date].[Date View].[Month].&[201601] 
    ) 
+0

「我什麼都嘗試過」 - 請讓我們看看你試圖 – whytheq

+0

對不起很多不同的東西列出的許多隨機的微小變化。 –

回答

0

這是一個潛在的方向是比較普遍:

WITH 
    MEMBER [Measures].[Start] AS 
    Min 
    (
     (EXISTING 
     [Date].[Date].[Date].MEMBERS) 
    ,IIF 
     (
     [Measures].[Internet Sales Amount] = 0 
     ,NULL 
     ,[Date].[Date].CurrentMember.MemberValue 
    ) 
    ) 
SELECT 
    NON EMPTY 
    { 
     [Measures].[Start] 
    ,[Measures].[Internet Sales Amount] 
    } ON COLUMNS 
,NON EMPTY 
    [Product].[Product Categories].[Product] ON ROWS 
FROM [Adventure Works] 
WHERE 
    [Date].[Calendar].[Calendar Year].&[2005]; 

它提供了以下:

enter image description here

+0

ITEM函數期望1參數的元組集表達式。使用了一個字符串或數字表達式。 –

+0

像這樣修改會給我1900-01-01在每一行 WITH MEMBER [Measures]。[Start] as {[Date]。[Date View]。[Date]}。item(0).membervalue –

+0

this現在已更新並且有一個通用的解決方案 – whytheq

0

這個工作,但它感覺有點像黑客,或者它感覺像它不健壯,我不熟悉mdx能夠打電話。

WITH MEMBER [Measures].[Start] as 
filter([Date].[Date View].[Month].&[201601].children, 
[Measures].[Whatevers]).item(0).membervalue 
+0

這只是硬編碼'.. [Month]。&[201601] .'你真的可以嘗試通過'EXISTING'關鍵字來推廣。 – whytheq

+0

好 - 現在我已經開始測試想法 - 我已經修改了我的答案 - 我之前發佈的垃圾道歉! – whytheq

相關問題