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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
alya1
Helper IV
Helper IV

Average age of customers by year

Hi All,

 

I have data tables like below:

All customer data including birthday and many other traits

IDBirthdayother columns...
1111/1/1995 
2222/2/2000 
3333/3/1890 
...... 


Historical customer list table showing the historical date and any ID that was an active customer on that date

IDUpload Date
1111/1/2020
2221/1/2020
1111/2/2020
2221/2/2020
3331/2/2020
...... till today

 

Calendar table with all dates from 1/1/2020 to today.

 

Relationships:

Calendar table is linked to historical table by upload date.

All customer data table is linked to historical table by ID. 

 

Is there a way to show average age of our active customers by year? Thank you!

 

1 ACCEPTED SOLUTION
gmsamborn
Super User
Super User

Hi @alya1 

 

I made up some random data and was wondering if these measures would help.

Age = 
    IF(
        MAX( 'Customer'[BirthDate] ),
        SELECTEDVALUE( 'Date'[Year] ) - YEAR( MAX( 'Customer'[BirthDate] ) )
    )


Avg Age = 
    AVERAGEX(
        ALLSELECTED( 'Historical'[ID] ),
        [Age]
    )

 

Let me know if you have any questions.

 

Avg Age.pbix

 

View solution in original post

5 REPLIES 5
gmsamborn
Super User
Super User

Hi @alya1 

 

I made up some random data and was wondering if these measures would help.

Age = 
    IF(
        MAX( 'Customer'[BirthDate] ),
        SELECTEDVALUE( 'Date'[Year] ) - YEAR( MAX( 'Customer'[BirthDate] ) )
    )


Avg Age = 
    AVERAGEX(
        ALLSELECTED( 'Historical'[ID] ),
        [Age]
    )

 

Let me know if you have any questions.

 

Avg Age.pbix

 

Hi gmsamborn, thank you very much for your reply!
I tried following along with your DAX but sadly it didn't work. I think it's because my Calendar table only have dates "from 1/1/2020 to today." So every customers age for year 2021 is 18 and 2022 is 19 and so on. Do you have any other ideas? 

Hi @alya1 

 

Is the realtionship between Historical and Customer set to both directions?

 

If that isn't the problem, can you please supply a pbix file with data that covers your problem as well as expected results from THAT data.

I think that was it! Thank you so much 😄 

@alya1 

 

I'm glad I could help.

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! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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