cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Helper II
Helper II

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
Community Support
Community Support

Hi, @atinakarim 

 

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
Community Support
Community Support

Hi, @atinakarim 

 

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

Super User IV
Super User IV

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

 



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

Super User III
Super User III

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
secondImage

Congratulations!

We are excited to announce the Power BI Super Users!

Wave Release 2

Check out the updates in Power BI.

Overview of Power BI 2020 release wave 2!

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

Mark your calendars and join us for our next Power BI Dev Camp!.

secondImage

The largest Power BI virtual conference

100+ sessions, 100+ speakers, Product managers, MVPs, and experts. All about Power BI. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors