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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Anonymous
Not applicable

DAX Measure to calculate monthly costs based on single date for each cost

Hi,

 

I have a table where each row represents a VM and an application with a planned decommission date and cost, in essence it looks something like this:

VMApplicationDecommission DateDecommission Cost
VM01Print application01.01.2023$1000
VM02Print application01.01.2023$1000
VM03File server01.04.2023$800
VM04Email server01.07.2023$1500

 

What I would like to do:

  • Create a DAX measure calculating the total monthly costs and see it on a timeline
  • The decommission costs for each VM/application should be counted in all months until the month where it is decommissioned. This means the DAX in question should return $3300 until 01.2023, $2300 between 01.2023-04.2023 and $1500 between 04.2023 and 07.2023, $0 after 07.2023. 
  • Then I would like to, if possible, use the date column to show the total decommission cost in a graph

What I tried:

TotalDecommissionCost = CALCULATE(SUM(Decommission Cost), ALL(Table)) - SUM(Decomission Cost)

 

This yielded wrong results.

Any suggestions welcome!

1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

Hi @Anonymous ,

According to your description, in my understanding, you want to calculate the sum of Decommission Cost when the date larger or equal to current date. In this way, 2023/1/1 will return 4300(1000+1000+800+1500), not 3300.

I this is the case, here's my solution.

Create a measure.

TotalDecommissionCost =
SUMX (
    FILTER (
        ALL ( 'Table' ),
        'Table'[Decommission Date] >= MAX ( 'Table'[Decommission Date] )
    ),
    'Table'[Decommission Cost]
)

Get the result.

vkalyjmsft_0-1656049806090.png

I attach the sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

1 REPLY 1
v-yanjiang-msft
Community Support
Community Support

Hi @Anonymous ,

According to your description, in my understanding, you want to calculate the sum of Decommission Cost when the date larger or equal to current date. In this way, 2023/1/1 will return 4300(1000+1000+800+1500), not 3300.

I this is the case, here's my solution.

Create a measure.

TotalDecommissionCost =
SUMX (
    FILTER (
        ALL ( 'Table' ),
        'Table'[Decommission Date] >= MAX ( 'Table'[Decommission Date] )
    ),
    'Table'[Decommission Cost]
)

Get the result.

vkalyjmsft_0-1656049806090.png

I attach the sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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