Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Johan
Advocate II
Advocate II

Accumulated value based on criteria

 

Hi,

I've got this measure to create:
show accumulated costs only in the month when the project is delivered

 

project table:
projectid deliverymonth
1 201702
2 201703


costs table
month projectid amount
201701 1 100
201702 1 200
201703 1 300
201701 2 111
201702 2 222
201703 2 333


result should show:
projectid month acc.costs at delivery
1 201701 0
1 201702 200
1 201703 0
2 201701 0
2 201702 0
2 201703 666

 

If tried sumx and if options, but no luck so far.

Thanks,
Johan.

 

 

 

 

 

 

1 ACCEPTED SOLUTION
v-sihou-msft
Microsoft Employee
Microsoft Employee

@Johan

 

I assume your two tables linked by Project Id. Then you just need to add a calculated column like below:

 

Cumulative =
IF (
    Costs[Month] = RELATED ( Project[DeliveryMonth] ),
    CALCULATE (
        SUM ( Costs[Amount] ),
        FILTER (
            Costs,
            Costs[Month] <= EARLIER ( Costs[Month] )
                && Costs[Project] = EARLIER ( Costs[Project] )
        )
    ),
    0
)

7.PNG

 

 

Regards,

View solution in original post

2 REPLIES 2
v-sihou-msft
Microsoft Employee
Microsoft Employee

@Johan

 

I assume your two tables linked by Project Id. Then you just need to add a calculated column like below:

 

Cumulative =
IF (
    Costs[Month] = RELATED ( Project[DeliveryMonth] ),
    CALCULATE (
        SUM ( Costs[Amount] ),
        FILTER (
            Costs,
            Costs[Month] <= EARLIER ( Costs[Month] )
                && Costs[Project] = EARLIER ( Costs[Project] )
        )
    ),
    0
)

7.PNG

 

 

Regards,

Thanks. 

 

through the msdn network I found a calculated measure :

 

if(maxx(month) = max(project[deliverymonth); [accumulated value];0) 

where [accumulated value] is the regular dax formula for accumulations.

 

 

I like your solution because for performance reasons it might be better to put into the table as new column. Though I think it should be a column in  the project table, since there are multiple cost lines, which would duplicate the value since in the month of delivery you can have multiple lines calculating the same column value.

 

Thanks for your input!

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors