Aggregated sum in DAX

本小妞迷上赌 提交于 2019-12-10 11:59:51

问题


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:

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?


回答1:


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] )
        )
    )


来源:https://stackoverflow.com/questions/50198333/aggregated-sum-in-dax

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!