dax中的动态总和选择不同的值 [英] Dynamic sum in dax picking distinct values
问题描述
以下是示例数据
Week Practice Type capacity Gen
1 BI c 80 0
1 BI c 80 1
1 BI sc 160 1
1 BI pc 240 0
1 BI pc 240 3
1 BI mc 1160 1
1 BI mc 1160 4
1 BI mc 1160 2
1 BI ac 440 1
1 BI d 40 0
1 BI d 40 3
我有一个数据透视图,其中有3个切片器,分别是PRactice,Type和gen。
I have a pivot chart, that has 3 slicers namely PRactice, Type, and gen.
不要选择任何切片器,它应该是一个不同的总和(容量),即2120。然后,当我单击类型切片器时,说mc Sum(capacity)应该是1160,然后只单击gen说3,然后清除其他过滤器,然后 sum(capacity)= 280
。
when I don't select any slicer, it should be a distinct sum(capacity) ie.,2120. Then when I click on type slicer say mc Sum(capacity) should be 1160 and click on only gen say 3 and clear other filters then sum(capacity) = 280
.
可能有很多做法,而且需要很多周。
There can be many practices and many weeks.
需要dax查询才能满足此要求。
Need dax query to meet this requirement.
推荐答案
您需要定义两个DAX度量:
You need to define two DAX measures:
Support:=MAX(Table1[capacity])
和
DistinctSumOfCapacity:=SUMX(DISTINCT(Table1[Type]),[Support])
现在,您可以将 DistinctSumOfCapacity
添加到数据透视表的value部分,您将获得不同的总和。
Now you can add DistinctSumOfCapacity
to the value section of your pivot and you'll get the distinct sum.
这篇关于dax中的动态总和选择不同的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!