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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Maximum Difference in Date Values

I have 5 different date value columns (each signifying the last scan date for 5 categories of devices). I want to create a column that would take the oldest date from these 5 columns and calculate the difference in days from TODAY. 

 

How should I do this?

 

 

1 ACCEPTED SOLUTION
v-alq-msft
Community Support
Community Support

Hi, @Anonymous 

 

Based on your description, I also suggest you use one date column. I created data t reproduce your scenario.

Table:

a1.png

 

You may create two measures as follows.

 

The oldest date = 
CALCULATE(
    MIN('Table'[Date]),
    ALL('Table')
)

Difference = 
DATEDIFF(
    [The oldest date],
    NOW(),
    DAY
)

 

 

Result:

a2.png

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-alq-msft
Community Support
Community Support

Hi, @Anonymous 

 

Based on your description, I also suggest you use one date column. I created data t reproduce your scenario.

Table:

a1.png

 

You may create two measures as follows.

 

The oldest date = 
CALCULATE(
    MIN('Table'[Date]),
    ALL('Table')
)

Difference = 
DATEDIFF(
    [The oldest date],
    NOW(),
    DAY
)

 

 

Result:

a2.png

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

I think the best way is, what suggested by @Ashish_Mathur .

You can try

 

min date =
var _tab = union(all(table[Date1]),all(table[Date2]),all(table[Date3]),all(table[Date4]),all(table[Date5]))
Return
minx(_tab,[date1])

 

I have not tried it so Just check name suggest for date by pressing [  in last line

 

Ashish_Mathur
Super User
Super User

Hi,

Instead of maintaining 5 column, we should have all dates in 1 column.  Share some data and show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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