Aggregated sum in DAX

2019-06-13 02:52发布

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:

enter image description here

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: enter image description here

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

1条回答
beautiful°
2楼-- · 2019-06-13 03:15

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] )
        )
    )
查看更多
登录 后发表回答