Ssas MDX-如何在最小值中跳过0值,以及如何排除某些百分比的结果?

Ssas MDX-如何在最小值中跳过0值,以及如何排除某些百分比的结果?,ssas,mdx,Ssas,Mdx,在我的立方体里我有 以MINaggregation作为衡量指标的收入 维度:[本地化][类型]和[中心] 维度:{[Date].[Year].&[2017],[Date].[Year].&[2018]} 我的问题是: What are the minimum earnings of the person who decides to buy apartments in the city center, excluding 5% of the lowest, within last 2 yea

在我的立方体里我有

  • MIN
    aggregation作为衡量指标的收入
  • 维度:[本地化][类型]和[中心]
  • 维度:{[Date].[Year].&[2017],[Date].[Year].&[2018]}
我的问题是:

What are the minimum earnings of the person who decides to buy
apartments in the city center, excluding 5% of the lowest, within
last 2 years?
现在,我的mdx查询如下所示:

SELECT
[Measures].[MinEarnings] ON COLUMNS
FROM [cube]
WHERE
(
    BottomCount ([Localization].[Type].&[center], 95, [Measures].[MinEarnings]),
    {[Date].[Year].&[2017], [Date].[Year].&[2018]}
)
我有两个问题:

  • 有些收入为0-我如何在计算中跳过它们
  • 如果我的查询正确地排除了最低收入的5%

  • 首先,您应该使用toppercent而不是bottomcount。你想要的是不在最后5%而不是最后5%的人的最低工资。Toppercent将为您提供最优质的95%

    其次,要筛选0,可以使用以下语法

    toppercent (
    filter([Localization].[Type].&[center], [Measures].[MinEarnings]>0)
    , 95, [Measures].[MinEarnings])
    
    即使现在将代码放在where子句中也可能不起作用,但是请尝试一下。我建议你把最上面的部分移到行中,然后订购,然后取最上面的1

    topcount(
    order(
    toppercent (
    filter([Localization].[Type].&[center], [Measures].[MinEarnings]>0)
    ,95, [Measures].[MinEarnings])
    ,[Measures].[MinEarnings],asc)
    ,1)
    
    我有一个例子,它给出了城市的minum销售金额,请注意,我已将NULL替换为0,以使其尽可能接近您的情况

    与会员[措施][互联网销售额2] 作为 当([Measures].[Internet Sales Amount])=null时,则0其他[Measures].[Internet Sales Amount]结束

    select [Measures].[Internet Sales Amount2]
    on columns ,
    topcount(order(toppercent(filter([Customer].[City].[City],[Measures].[Internet Sales Amount2]>0),95,[Measures].[Internet Sales Amount2]),[Measures].[Internet Sales Amount2],asc),1)
     on rows 
    from [Adventure Works]
    where [Customer].[Country].&[Canada]
    
    下图是topcount 1之前的结果

    @SigGP运气好吗?