DAX中的汇总金额 [英] Aggregated sum in DAX

查看:107
本文介绍了DAX中的汇总金额的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在出租一辆汽车,我用自己的东西,但也出租给他人使用。我每个月可以开车2000公里,所以我试图做一个区域枢纽图表,以跟踪我使用它的数量与出租的数量。

I'm leasing a car, which I use my self, but also rent out for other people to use. I have 2000km I can drive each month, so I'm trying to do an area pivot graph which will track how much I use it vs how much it's rented out.

我有一个表列,其中包含租用的里程数和我自己的里程数

I have a table column consisting of the rented mileage and my own mileage

 ___________________________________
|Date    |Rented mileage|Own mileage|
|23/03-18|           315|        117|
|07-04-18|           255|        888|
|07/04-18|           349|          0|
|13/04-18|           114|          0|
|21/04-18|           246|        113|
|28/04-18|          1253|          0|
|01/05-18|          1253|          0|

到目前为止,我有两种测量方法:

So far I have two measures:

RentedMileage:=SUM(Table1[Rented Mileage])
OwnMileage:=SUM(Table1[Own Mileage])

其中,当我绘制到数据透视图时,如下所示:

Which, when I plot to the pivot chart looks like this:

我希望汇总里程,并有一条线,当我超过2000公里限制时会显示该线,因此它看起来像这:

I would like the mileage to be aggregated and have a Line which shown when I'm exceeding my 2000 km limit, so it would look something like this:

但是我一辈子都无法弄清楚如何进行汇总表的值?

But I can't for the life of me figure out how to do an aggregated value of my table?

推荐答案

问题通过在度量中添加以下代码行来解决:

The issue was solved by adding following line of code to the measure:

Cumulative Quantity :=
    CALCULATE (
        SUM ( Transactions[Quantity] ),
        FILTER (
            ALL ( 'Date'[Date] ),
            'Date'[Date] <= MAX ( 'Date'[Date] )
        )
    )

这篇关于DAX中的汇总金额的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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