按类别显示单个类别的 DAX 总计 [英] DAX Total by category displayed for single category

查看:25
本文介绍了按类别显示单个类别的 DAX 总计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要单个类别的类别总数.就像图片中的 FruitOnly 度量:

我有一个衡量标准:

按类别总计 = CALCULATE([Sales], ALLEXCEPT('Table','Table'[Category]))

但我只想要水果的结果,所有其他类别都有空白.

FruitOnly = IF(MAX('Table'[Category])="Fruit", [Total by category], BLANK())

这样的结果是残废的,因为该度量的总和应该是 45.

难道没有更简单的方法来获得 FruitOnly 结果吗?就像度量一样:

Fruits raw sales = CALCULATE([Sales], 'Table'[Category]="Fruit")

只返回水果的结果?

现在奖金问题提升了达斯维德级别的挑战.如果表格视觉中没有显示类别,只显示产品,那么导致 FruitOnly 的度量是否可行?

我拼命的努力在一个文件中可供下载:

I want a total by category for single category. Just like the FruitOnly measure in a picture:

I have a measure:

Total by category = CALCULATE([Sales], ALLEXCEPT('Table','Table'[Category]))

But I want the results only for Fruit, having blanks for all the other categories.

FruitOnly = IF(MAX('Table'[Category])="Fruit", [Total by category], BLANK())

Such a result is cripple because there is no total sum for that measure which should be 45.

Wouldn't there be any simpler way to get the FruitOnly results? Just like the measure:

Fruits raw sales = CALCULATE([Sales], 'Table'[Category]="Fruit")

returns the results only for fruits?

And now the bonus question lifting the challenge to Darth Vader level. Would a measure resulting in FruitOnly be possible if there was no Category displayed in table visual, just Product?

My desperate efforts are here in a file to download:

TotalByCategoryForSingleCategory.pbix

解决方案

This will do the trick:

FruitOnly =
CALCULATE (
    [Total by category],
    FILTER ( 'Table', 'Table'[Category] = "Fruit" )
)

I tried it out with your .pbix and I got the following:

这篇关于按类别显示单个类别的 DAX 总计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆