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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
GeorgeFP
Helper I
Helper I

Calculate the age of the asset at any selected date

Good day, and thanks for reading.

I hope you can point me in the right direction for a better solution than my current one, which lacks flexibility. I have been using calculated columns for a few predefined dates and calculating the asset age at that date (i.e., the user can only select a date from the predefined dates), with the PO date always the “start” to calculate the age.

I aim to show the user all the assets (via a table) with their "age" at the date selected from the dropdown. To answer the question:  “Show me the age of all the assets that will be 10 years old on <selected date>”.

The Table: (image of the table attached)

1 x Asset table with

3 x columns a) Asset Name, b) PO number, c) PO date

I appreciate your reading, and thanks in advance

Sincerely, George


Challenge to calculate the age at any selected date.png

1 ACCEPTED SOLUTION
danextian
Super User
Super User

Hi @GeorgeFP 

 

Calculating age based on a slicer selection is straightforward, but categorizing them into years while accounting for leap years is quite complex. For the sake of simplicity and illustration, in my sample PBIX, years are simply calculated as age in days divided by 365, rounded down to the nearest integer.

 

The age is dynamically calculated using a measure referenced to a disconnected dates table. This measure is then materialized by using another table, allowing ages to be sliced, diced, and categorized in visuals.

PO Age in Days =
DATEDIFF (
    // Calculates the difference between two dates
    SELECTEDVALUE ( PO[PO Date] ),
    // Gets the single value of PO Date for the current context
    MAX ( 'As of Date'[Date] ),
    // Gets the maximum date from the 'As of Date' table
    DAY // Specifies that the difference should be in days
)
PO by Age =
CALCULATE (
    COUNTROWS ( PO ),
    // Counts the rows in the PO table
    FILTER (
        // Applies a filter to the table
        VALUES ( PO[PO Date] ),
        // Creates a list of unique PO Dates
        [PO Age in Days]
            IN VALUES ( Ages[Age in Days] ) // Filters the rows where PO Age in Days matches Ages[Age in Days]
    )
)

  

danextian_0-1736687460482.png

Please see the sample pbix.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

4 REPLIES 4
GeorgeFP
Helper I
Helper I

Thank you @danextian - its exactly what I needed.

Regards George

danextian
Super User
Super User

Hi @GeorgeFP 

 

Calculating age based on a slicer selection is straightforward, but categorizing them into years while accounting for leap years is quite complex. For the sake of simplicity and illustration, in my sample PBIX, years are simply calculated as age in days divided by 365, rounded down to the nearest integer.

 

The age is dynamically calculated using a measure referenced to a disconnected dates table. This measure is then materialized by using another table, allowing ages to be sliced, diced, and categorized in visuals.

PO Age in Days =
DATEDIFF (
    // Calculates the difference between two dates
    SELECTEDVALUE ( PO[PO Date] ),
    // Gets the single value of PO Date for the current context
    MAX ( 'As of Date'[Date] ),
    // Gets the maximum date from the 'As of Date' table
    DAY // Specifies that the difference should be in days
)
PO by Age =
CALCULATE (
    COUNTROWS ( PO ),
    // Counts the rows in the PO table
    FILTER (
        // Applies a filter to the table
        VALUES ( PO[PO Date] ),
        // Creates a list of unique PO Dates
        [PO Age in Days]
            IN VALUES ( Ages[Age in Days] ) // Filters the rows where PO Age in Days matches Ages[Age in Days]
    )
)

  

danextian_0-1736687460482.png

Please see the sample pbix.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

@danextian 

Wow, no wonder I did not get it right 🙂

 

I will test immediately and revert with my findings.

Regards George

Anonymous
Not applicable

Hi @GeorgeFP ,

Whether the pbix file provided by danextian can help you get the expected result? If yes, could you please mark his reply as Answered? It would be helpful to others in the community find the solution easily if they face the similar problm

Best Regards

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors