Forum Discussion

PSak's avatar
PSak
Regular Visitor
5 years ago
Solved

Asset Life Cycle Calculation

Hi everyone,   I have the following dataset that shows basic information of several assets:   Asset No Whole asset replacement cost Last Replaced Expected Life End of Life Subs...
  • ERD's avatar
    5 years ago

    PSak ,

    I think it might be easier to have all Expected Life End years in one column.

    I assumed that you need a chart with a forecast for the years 2021-2030. So my first thought was about the loop (while year <=2030, count next replacement year). I did it with Power Query as well, but using a bit different approach:

    1. Create a function that will provide a list of replacement years for each Last Replaced year

     

    (endyear as number, life as number, maxYear as number, optional results as list) =>
    let
    firstValue = endyear+life,
    output = List.Generate(
        ()=>firstValue,
        each _<= maxYear, each _+life,
        each _
    )
    in
    output

     

    2. Optional: You can duplicate your query to have only 3 columns as a result (assuming your initial query has more columns, etc.).

    3. Add column - Invoke the function from the previous step:

    • New column name - provide the name you prefer
    • Function query - name of the function from step 1
    • endyear - Last Replaced column
    • life - Expected Life column
    • maxYear - put the max year for the chart. In provided example - 2030

    As a result you will get a list of years for each row in the new column.

    4. Use the expand icon in the upper-right corner of the column label and select Expand to New Rows.

    5. Optional: delete all unnecessary columns.