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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
vnqt
Helper V
Helper V

Average age of machines per year

Hi, 

 

I have the following view of the number of machines with the purchased year (date) : 

vnqt_0-1722348565403.png

 

I would like to create another view of the average age of the machines over year :

 

For example, the 4 in 2014 : Total months since purchased date until today month / total machines of that year 

The average age should be year.

Here is the sample data : 

 

MachinePurchase date
Machine 124/04/2014
Machine 225/04/2014
Machine 326/04/2014
Machine 427/04/2014
Machine 528/04/2015
Machine 629/04/2015
Machine 730/04/2015
Machine 809/07/2016
Machine 910/07/2016
Machine 1011/07/2016
Machine 1112/07/2016
Machine 1213/07/2016
Machine 1314/07/2016
Machine 1404/03/2017
Machine 1508/08/2018
Machine 1608/08/2018
Machine 1708/08/2018
Machine 1808/08/2018
Machine 1904/05/2019
Machine 2007/05/2020
Machine 2107/05/2020
Machine 2207/05/2020
Machine 2307/05/2020
Machine 2430/04/2021
Machine 2530/04/2021
Machine 2630/04/2021
Machine 2706/09/2022
Machine 2809/06/2023
Machine 2909/06/2023
Machine 3009/06/2023
Machine 3103/07/2024
Machine 3203/07/2024
Machine 3303/07/2024
Machine 3403/07/2024

 

Many thanks in advance for your help.

 

1 ACCEPTED SOLUTION
rajendraongole1
Super User
Super User

Hi @vnqt - Thanks for sharing the data,

 

first lets create a calculated column ageinmonths as below:

AgeInMonths = DATEDIFF('Agemachine'[Purchase date], TODAY(), MONTH)
 
TotalAgeInMonths =
SUMX(
    FILTER(
        'Agemachine',
        'Agemachine'[PurchaseYear] = MAX('Agemachine'[PurchaseYear])
    ),
    'Agemachine'[AgeInMonths]
)
rajendraongole1_0-1722350658620.png

 

One more new column for years

AgeInYears = 'Agemachine'[AgeInMonths] / 12
rajendraongole1_1-1722350697518.png
another column for year from purchase date
PurchaseYear = YEAR('Agemachine'[Purchase date])
rajendraongole1_3-1722350782538.png

 

Last Lets try to create measure to get the average of age in years as below:

rajendraongole1_4-1722350845188.png

 

AverageAgeInYears =
AVERAGEX(
FILTER(
'Machines',
'Machines'[PurchaseYear] = MAX('Machines'[PurchaseYear])
),
'Machines'[AgeInYears]
)

 

rajendraongole1_5-1722350915846.png

 

 

Hope it helps

 

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

4 REPLIES 4
rajendraongole1
Super User
Super User

Hi @vnqt - Thanks for sharing the data,

 

first lets create a calculated column ageinmonths as below:

AgeInMonths = DATEDIFF('Agemachine'[Purchase date], TODAY(), MONTH)
 
TotalAgeInMonths =
SUMX(
    FILTER(
        'Agemachine',
        'Agemachine'[PurchaseYear] = MAX('Agemachine'[PurchaseYear])
    ),
    'Agemachine'[AgeInMonths]
)
rajendraongole1_0-1722350658620.png

 

One more new column for years

AgeInYears = 'Agemachine'[AgeInMonths] / 12
rajendraongole1_1-1722350697518.png
another column for year from purchase date
PurchaseYear = YEAR('Agemachine'[Purchase date])
rajendraongole1_3-1722350782538.png

 

Last Lets try to create measure to get the average of age in years as below:

rajendraongole1_4-1722350845188.png

 

AverageAgeInYears =
AVERAGEX(
FILTER(
'Machines',
'Machines'[PurchaseYear] = MAX('Machines'[PurchaseYear])
),
'Machines'[AgeInYears]
)

 

rajendraongole1_5-1722350915846.png

 

 

Hope it helps

 

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Many thanks for your help . 

rajendraongole1
Super User
Super User

Hi @vnqt - Can you please share sample data for reference in excel? it helps to understand the columns and if there is any date field.

 

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





@rajendraongole1  Hi, thanks for your reply, i just add the sample data 

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!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.