I have a problem with a MDX request:

The following query gives me the good partial results

WITH 
 SET  [Paiments Encaisse] AS    { [Type Paiement].[Type Paiement Id].&[13]
    ,[Type Paiement].[Type Paiement Id].&[20]
    ,[Type Paiement].[Type Paiement Id].&[31]
    ,[Type Paiement].[Type Paiement Id].&[62]} 
MEMBER [Measures].[CA Encaissé]
AS
    SUM(
     [Paiments Encaisse],[Measures].[Montant HT Partage Encaisse]
    )
MEMBER Measures.[CA Encaissé-E] AS [Measures].[CA Encaissé]
MEMBER MEASURES.[CA Encaissé-H] AS 
([Measures].[CA Encaissé],[Hors En CDP].[Hors ou En CDP].&[False] )

SELECT 
{Measures.[CA Encaissé-E],MEASURES.[CA Encaissé-H]} ON 0,
NON EMPTY{ 
{[Hors En CDP].[Hors ou En CDP].&[True]} * VISUALTOTALS([Employes].[Hie Societe].MEMBERS)*
[CDP Propriétaire].[Centre de Profits].[All]

} ON 1
FROM NON VISUAL
( SELECT {[Employes].[Societe].&[1234]} ON 0,{[CDP Propriétaire].[Societe].&[1234]} ON 1 FROM [Prévisions] )
WHERE (
[Type Fantome].[Val].&[False],
[Date Facturation du Paiement].[Year].&[2011-01-01T00:00:00],
[Date Paiement].[Year].&[2011-01-01T00:00:00],
[Date Facturation Opération].[Year].&[2011-01-01T00:00:00])

However, the follwoing query, that aims at giving me the whole results, returns me less rows on the first part of the UNION than the first query, which baffles me

WITH 
 SET  [Paiments Encaisse] AS    { [Type Paiement].[Type Paiement Id].&[13]
    ,[Type Paiement].[Type Paiement Id].&[20]
    ,[Type Paiement].[Type Paiement Id].&[31]
    ,[Type Paiement].[Type Paiement Id].&[62]} 
MEMBER [Measures].[CA Encaissé]
AS
    SUM(
     [Paiments Encaisse],[Measures].[Montant HT Partage Encaisse]
    )
MEMBER Measures.[CA Encaissé-E] AS [Measures].[CA Encaissé]
MEMBER MEASURES.[CA Encaissé-H] AS 
([Measures].[CA Encaissé],[Hors En CDP].[Hors ou En CDP].&[False] )

SELECT 
{Measures.[CA Encaissé-E],MEASURES.[CA Encaissé-H]} ON 0,
NON EMPTY{ UNION
({[Hors En CDP].[Hors ou En CDP].&[True]} * VISUALTOTALS([Employes].[Hie Societe].MEMBERS)*
[CDP Propriétaire].[Centre de Profits].[All]
 , {[Hors en CDP].[Hors ou En CDP].&[False],[Hors en CDP].[Hors ou En CDP].[All]}
*  {[Employes].[Hie Societe].[All]} * 
       VISUALTOTALS  ([CDP Propriétaire].[Centre de Profits].ALLMEMBERS
  ),ALL
)} ON 1
FROM NON VISUAL
( SELECT {[Employes].[Societe].&[1234]} ON 0,{[CDP Propriétaire].[Societe].&[1234]} ON 1 FROM [Prévisions] )
WHERE (
[Type Fantome].[Val].&[False],
[Date Facturation du Paiement].[Year].&[2011-01-01T00:00:00],
[Date Paiement].[Year].&[2011-01-01T00:00:00],
[Date Facturation Opération].[Year].&[2011-01-01T00:00:00])

What's more, the column Measures.[CA Encaissé-H] is always NULL in the second query, even on lines where there should be a value.

What I do not understand is why the results in the first part of the union are influenced by what happens in the second part. Could someone please explain it to me ?

有帮助吗?

解决方案 2

META : I attached a big bounty to this question, so far, the only answer is a description of the effects, not the inner working of VISUALTOTALS.

其他提示

I'm not a specialist of SSAS; but I can share my experience with icCube; VisualTotal() is changing the way a hierarchy is actually aggregated and if you've several calls of this function into the same request this become quite weird as possibly non deterministic (depending on order of evaluation) and difficult to understand.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top