如何基于DAX Powerpivot中的另一列求和 [英] How to SUM a Column based on another column in DAX Powerpivot

查看:326
本文介绍了如何基于DAX Powerpivot中的另一列求和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里是示例,

+------+----+
| CARS |  3 |
| CARS |  4 |
| CARS |  6 |
| CARS | 76 |
| CARS |  4 |
| CARS |  3 |
| SUV  | 32 |
| SUV  |  3 |
| SUV  |  3 |
| SUV  |  2 |
| SUV  |  3 |
| SUV  |  5 |
+------+----+

我要添加带有这样的数据的新计算列

I want to add a new calculated column with data like this

+------+----+------+
| CARS |  3 |  96  |
| CARS |  4 |  96  |
| CARS |  6 |  96  |
| CARS | 76 |  96  |
| CARS |  4 |  96  |
| CARS |  3 |  96  |
| SUV  | 32 |  48  |
| SUV  |  3 |  48  |
| SUV  |  3 |  48  |
| SUV  |  2 |  48  |
| SUV  |  3 |  48  |
| SUV  |  5 |  48  |
+------+----+------+ 

它将在哪里汇总车辆类型的数字列。 DAX命令将获得什么?我需要第三列来总结所有Cars..CARS行的总和为96,总结所有Suv的总和,对于suv的所有行的总和为48。请帮助

Where it would sum up the number column for the type of vehicle. What would be the DAX command to get this? I need a third column that sums up all Cars..that is 96 for the CARS row, and sums up all Suvs, that is 48 for all rows that are suvs. Please help

推荐答案

您可以创建一个计算得出的度量来完成此任务。我将您的数据导入了Power Pivot模型。然后,我添加了以下计算得出的度量:

You can create a calculated measure to accomplish this. I imported your data into a Power Pivot model. Then I added the following calculated measure:

Type Subtotal:=CALCULATE( SUM( [Value]), ALLEXCEPT(Table2, Table2[Type]))

因此,当我制作数据透视表时,会得到所需的结果。

So when I make a pivot table I get the desired result.

这篇关于如何基于DAX Powerpivot中的另一列求和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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