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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Vaishali04
Helper II
Helper II

calculate age of value last updated

Hi,

 

I have below data. I want to calculate the age of latest comment of a circuit. for eg. for circuit "B" latest comment is "woking". That comment is not update from past 5 days. So it's age is 5.

 

DateCircuit Comment
1/2/2019A 
1/3/2019A 
1/4/2019A 
1/5/2019A 
1/6/2019A 
1/7/2019A 
1/2/2019Bnot ok
1/3/2019Bnot ok
1/4/2019Bnot ok
1/5/2019Bworking
1/6/2019Bworking
1/7/2019Bworking
1/8/2019Bworking
1/9/2019Bworking
1/2/2019Cstatic data
1/3/2019Cstatic data
1/4/2019Cstatic data
1/5/2019Cstatic data
1/6/2019Cstatic data
1/7/2019Cstatic data
1/8/2019Cworking as desired
1/9/2019Cworking as desired
1/10/2019Cworking as desired
1/11/2019Cworking as desired

 

Desired data

 

DateCircuit CommentAge
1/7/2019A 0
1/9/2019Bworking5
1/11/2019Cworking as desired4

 

Can anyone please help with DAX logic for calculating Age column?

1 REPLY 1
Greg_Deckler
Super User
Super User

Well, you can get the last status using something like Lookup Min/Max: https://community.powerbi.com/t5/Quick-Measures-Gallery/Lookup-Min-Max/m-p/985814#M434

 

You can get the max date using just MAX. 

 

A simple age could be calculated by combing these two, so let's say you have a variable __LastComment and you have the max date, __MaxDate, you could do something like:

 

COUNTROWS(FILTER('Table',[Date] <= __MaxDate && [Circuit Comment] = __LastComment))

 

But, the issue I foresee is if you have older comments where the comment matches but there are different comments in between. For that circumstance I would have to put some thought into it but maybe something along the lines of Cthulhu. https://community.powerbi.com/t5/Quick-Measures-Gallery/Cthulhu/m-p/509739#M211

 

In fact, if you had Cthulhu, you could just take the value of Cthulhu at your max date and be done.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.

Top Solution Authors