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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
MuppetyMe
Helper I
Helper I

DATEDIFF with CALCULATE, USERELATIONSHIP, and TODAY()

I have 2 tables; a Calendar table (containing a full, continuous range of dates from 1/1/2020 to 12/31/2027) and a Data table. There are multiple inactive relationships between the two as my Data table contains several different dates. 

 

The Data table contains a "Create Date", and am trying to figure out the age of an item via the difference between TODAY() and Create Date. 

 

In my mind, the measure should be pretty straigh forward: Age = CALCULATE (DATEDIFF (USERELATIONSHIP ('Calendar' [date], 'Data' [Create Date]), TODAY(), DAY)), but it does not work. Thoughts or suggestions?? 

9 REPLIES 9
MuppetyMe
Helper I
Helper I

@lbendlin this is obviously completely bogus data, but gives the basic gist. The data table has dozens of additional columns and thousands of rows. Each of the date fields have indirect connections to the Calendar table. Ultimately, I need to be able to create a date filter using the Calendar table. 

 

I understand that the simplest solution would be to create 4 different date filters using data in the table, but that's not what we're aiming to do. Hopefully this helps to explain what I'm after. 

 

Data

ReferenceCreate DateDate1Date2Date3
14/21/20215/3/20215/12/20215/21/2021
29/17/20219/29/202110/8/202110/17/2021
36/12/20226/24/20227/3/20227/12/2022
410/10/202210/22/202210/31/202211/9/2022
51/4/20231/16/20231/25/20232/3/2023
63/23/20234/4/20234/13/20234/22/2023
75/29/20246/10/20246/19/20246/28/2024
88/19/20248/31/20249/9/20249/18/2024

 

Calendar

Date
4/21/2021
5/3/2021
5/12/2021
5/21/2021
9/17/2021
9/29/2021
10/8/2021
10/17/2021
6/12/2022
6/24/2022
7/3/2022
7/12/2022
10/10/2022
10/22/2022
10/31/2022
11/9/2022
1/4/2023
1/16/2023
1/25/2023
2/3/2023
3/23/2023
4/4/2023
4/13/2023
4/22/2023
5/29/2024
6/10/2024
6/19/2024
6/28/2024
8/19/2024
8/31/2024
9/9/2024
9/18/2024

Your calendar must be contiguous and covering.  No gaps allowed.

You don't need a calendar if you are operating with TODAY() though.

 

lbendlin_0-1734127714387.png

 

 

Busted. The calendar table is contiguous and covering in the real dataset - thought I could cut corners for the example, but not the case. So that being said, @lbendlin, any other thoughts on how I might be able to accomplish? 

I showed the option without calendar. Please clarify what else you need.

Looking for the solution WITH a contiguous and covering calendar table. 

Please provide sample data that fully covers your issue.
Please show the expected outcome based on the sample data you provided.

johnt75
Super User
Super User

You can use

Age =
SUMX ( 'Data', DATEDIFF ( 'Data'[Create date], TODAY (), DAY ) )

Thanks @johnt75, this does work, but unfortunately not the way I need it to.

lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Please show the expected outcome based on the sample data you provided.

Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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