รวม 2 แบบสอบถาม mdx

ฉันมีคำถาม MDX 2 รายการจากคิวบ์เดียวกัน ทั้งสองใช้หน่วยวัดเดียวกันแต่มีชุดเวลาต่างกัน (ชุดเวลาทั้งสองมีมิติเดียวกันแต่มีลำดับชั้นต่างกัน)

ฉันต้องการรวมไว้ในผลลัพธ์ของตารางเดียวกัน ดังนั้นจะนำเสนอ 2 หน่วยวัด (ตัดตามชุดที่ต่างกัน) และมิติเวลาอื่น ("วันในสัปดาห์") ที่ใช้มิติเวลาเดียวกันด้วย แบบสอบถามสามารถรันแยกกันได้ดังนี้:

   with member [Measures].[AVG_6_WEEKS] as 
     [Measures].[Number of Answered Comms] /6
    select 
    nonempty([Comm Date UTC].[Day of Week].children)
    on 0, 
    [Measures].[AVG_6_WEEKS]
    on 1 
    from (select {LASTPERIODS( 42,[Comm Date UTC].[Year Month Day].lastsibling.lastchild.lastchild.lastchild.prevmember )}
    on 0 from comms)

;
 with member [Measures].[Answered Comms] as 
 [Measures].[Number of Answered Comms] 
select 
nonempty([Comm Date UTC].[Day of Week].children)
on 0, 
[Measures].[Answered Comms]
on 1 
from (select {LASTPERIODS( 7,[Comm Date UTC].[Year Month 
Day].lastsibling.lastchild.lastchild.lastchild.prevmember )}
    on 0 from comms)

มันสามารถทำได้? ฉันได้รับข้อผิดพลาดเสมอว่าไม่สามารถใช้ลำดับชั้นเวลาเดียวกันในการสืบค้นได้… มีความคิดเห็นไหม บางอย่างเช่น SQL ฉันสามารถเข้าร่วม 2 มุมมองได้หรือไม่

ขอบคุณ

โยนี่.


person Yoni    schedule 03.11.2014    source แหล่งที่มา


คำตอบ (1)


MDX ต่อไปนี้ควรทำเช่นนั้น:

with member [Measures].[AVG_6_WEEKS] as 
     Aggregate({LASTPERIODS( 42,[Comm Date UTC].[Year Month Day].lastsibling.lastchild.lastchild.lastchild.prevmember )},
               [Measures].[Number of Answered Comms] /6
              )
     member [Measures].[Answered Comms] as 
     Aggregate({LASTPERIODS( 7,[Comm Date UTC].[Year Month Day].lastsibling.lastchild.lastchild.lastchild.prevmember )},
               [Measures].[Number of Answered Comms]
              ) 
select 
nonempty([Comm Date UTC].[Day of Week].children)
on 0, 
{ [Measures].[AVG_6_WEEKS], [Measures].[Answered Comms] }
on 1 
from comms

ฉันย้ายบริบทจากการเลือกย่อยในแบบสอบถามของคุณไปยังคำจำกัดความสมาชิกโดยใช้ฟังก์ชัน Aggregate

person FrankPl    schedule 04.11.2014
comment
ขอบคุณ Frank แต่การใช้สคริปต์นี้ทำให้เกิดข้อผิดพลาดในตารางผลลัพธ์: ไม่สามารถใช้ฟังก์ชันรวมกับสมาชิกที่คำนวณได้ในมิติการวัด - person Yoni; 06.11.2014