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

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

问题描述

我想要一个类别的总计类别.就像图片中的FruitOnly测量一样:

我有一个措施:

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

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

  FruitOnly = IF(MAX('Table'[Category])="Fruit",[按类别总计],BLANK()) 

这样的结果很严重,因为该度量标准的总和不应该为45.

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

 水果原始销售额= CALCULATE([销售],'表'[类别] =水果") 

仅返回水果的结果?

现在,奖金问题将挑战提升到了达斯·维达(Darth Vader)的水平.如果在表格视觉中没有显示类别,而仅在产品中显示,那么是否有可能导致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天全站免登陆