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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
coding7
Frequent Visitor

Calculate the amortized cost

Hi all,

 

I'm trying to create a dax measure to calculate the amortized cost.

The amortized cost shows the cost of the reservations spread over the total period of the reservation.

I tried to check microsoft documentation that explains how can I calculate the amortized cost and it shows an example How Azure calculates amortized costs

 

The below screenshot shows the combination of azure plan & reservations

 
 

dkSMf.png

 

And the alternative is current approach where I have the actual cost, if a reservation is order on may 1, all the cost will be on that day and not spread over the total period: 

 

R11R5.png

I've a charge start date column and a charge end date column and I've a measure called reserved instances cost:

 

 

Reserved Instances Cost = VAR countsrows = COUNTROWS ( 'Fact Partner Center Costs' ) VAR measure_cost = CALCULATE ( SUM ( 'Fact Partner Center Costs'[Total Amount] ), KEEPFILTERS ( 'Fact Partner Center Costs'[Category] = "Reserved Instances" ) ) return CALCULATE( measure_cost, FILTER ( 'Fact Partner Center Costs', countsrows > 0 ), KEEPFILTERS( 'Dim Azure Reserved Instances Contract'[Contract Client Id]<> BLANK () ) )

 

 

and after I tried to create this measure:

 

 

Reserved Instances Daily Amortized Cost = 
SUMX (
    'Fact Partner Center Costs',
    VAR ContextDate = MAX ( 'Date'[Date] )
    VAR CostStartDate = CALCULATE ( MIN ( 'Fact Partner Center Costs'[Charge Start] ), ALL ( 'Date' ) )
    VAR CostEndDate = CALCULATE ( MAX ( 'Fact Partner Center Costs'[Charge End Date] ), ALL ( 'Date' ) )
    VAR ReservedInstancesCost =
        CALCULATE (
            SUMX ( VALUES ( 'Date'[Day] ), [Reserved Instances Cost] ),
            ALL ( 'Date' )
        )

    RETURN

    IF (

        ContextDate >= CostStartDate && ContextDate <= CostEndDate,

        DIVIDE ( ReservedInstancesCost, COUNTROWS ( DATESBETWEEN ( 'Date'[Date], CostStartDate, CostEndDate ) ), 0 ),

        BLANK ()

    )

)

 

 

It showing the correct values but If I apply a filter to one of the slicers I have, called Azure Reserved Instances Contract Key, it doesn't break down the values ​​by day, only for the 22nd

 

coding7_0-1691576003829.png

Thanks a lot !

1 REPLY 1
amitchandak
Super User
Super User

@coding7 , check if this approach can help
Measure way
Power BI Dax Measure- Allocate data between Range: https://youtu.be/O653vwLTUzM

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.