[英]Power BI DAX Sum By Year
Very new to Power BI and DAX and would appreciate a push in the right direction with this, seemingly simple, scenario, please.对 Power BI 和 DAX 非常陌生,希望通过这个看似简单的场景向正确的方向推动。 I have the following dataset:
我有以下数据集:
Job Name Quarter Year Cost
alpha 1 2019 210
alpha 2 2019 100
alpha 3 2019 90
alpha 4 2019 28
beta 1 2020 100
kappa 1 2019 100
kappa 2 2019 90
beta 2 2020 100
beta 3 2020 75
beta 4 2020 30
kappa 3 2019 10
kappa 4 2019 30
All I am trying to do is get a measure/calculated column which calculates the total [Cost] per [Job Name] for each year.我想要做的就是获取一个度量/计算列,计算每年每个 [Job Name] 的总 [Cost]。 So for example I would get, for alpha, the value: 428. For kappa it would be: 230. Thanks!
因此,例如,对于 alpha,我会得到值:428。对于 kappa,它将是:230。谢谢!
Use the below DAX to obtain the above result: New Table:使用下面的 DAX 得到上面的结果: 新表:
SUMMARIZE('Table','Table'[Job Name],"New Column",SUM('Table'[Cost]))
Using SUMMARIZE (as @Shilpa suggests) will return/add a new table to your report data source.使用 SUMMARIZE(如@Shilpa 建议的那样)将向您的报告数据源返回/添加一个新表。 I think this is not your requirement.
我认为这不是您的要求。
As you are looking for a solution using a measure or a calculated column, lets know a bit details about them as they are not same with the functionality-当您正在寻找使用度量或计算列的解决方案时,请了解有关它们的一些详细信息,因为它们与功能不同-
Calculated columns:计算列:
Measures:措施:
Now, for your scenario/requirement I think you need a simple measure as below-现在,对于您的场景/要求,我认为您需要一个简单的措施,如下所示-
total_cost = SUM('your_table'[Cost])
Your measure is ready now.你的措施现在准备好了。 Just pull column "Job Name" and measure "total_cost" to you visual.
只需拉出“工作名称”列并测量“total_cost”即可。 You will get your expected output. You can use slicer to check your value in/for different dimension.
您将获得预期的 output。您可以使用切片器检查不同维度的值。 Just play around:)
随便玩玩:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.