获取 Power BI 中聚合 bin 的度量计数

时间:2020-12-19 11:08:58

标签: powerbi dax

我有以下数据:

enter image description here

我在 dax 中为产品计数和总金额创建了 2 个度量。

产品计数=DistinctCount(table[Product])

Amount Total=sum(table[Amount])

enter image description here

我想显示如下输出:

enter image description here

为此,我使用开关盒创建了 2 个度量产品密度带和数量带。 但我无法获得每个乐队的 id 计数。 请帮忙。

1 个答案:

答案 0 :(得分:1)

我们需要两个配置表

Amount Band

enter image description here

还有 Product Density Band

Product Density Band table

现在我们可以定义两个度量来统计配置表选择中的数量和产品数量

Amount Total Band = 
COUNTROWS(
    FILTER(
        ALL( 'Table'[Id] ),
        [Amount Total] > MIN( 'Amount Band'[From] )
            && [Amount Total] <= MAX( 'Amount Band'[To] )
    )
)

Product Count Density Band = 
COUNTROWS(
    FILTER(
        ALL( 'Table'[Id] ),
        [Product Count] >= MIN( 'Product Density Band'[Product Density Band] )
            && [Product Count] <= MAX( 'Product Density Band'[Product Density Band] )
    )
)

在带有配置表的表中使用的这些度量提供了所需的结果

resulting table visuals