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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
legendsfan
Frequent Visitor

Finding the most recent value change

Requirement:  Create a custom column that lists the most recent updated start date.  
Background: PSOW # is always required. PCR # is only used if there are ammendments to orginal PSOW #.  PCR # always starts with 1 and counts up.  Est Start Date is not required to be updated in a PCR.  There can be multiple PCR #'s and for capturing date I'm only concerned with the most recent change to start date.

Problem: I need a way to scan backwards from most recent change to original PSOW # which has no PCR #.

Explanation of PSOW # 100:  There are 4 entries (original submission and 3 PCR.  I don't want date from most recent PCR #3 because it is NULL.  I need the most recent PCR entry where there was a date.

 

How can I capture in a custom column the most recent Est Start Date entry for each PSOW?

 

Source Data:

PSOW #PCR #CostEst Start Date
100 100001/1/2017
100120002/1/2017
10023000 
10032000 
101 50003/1/2017
10112000 
10121000 

 

Expected Results:

PSOW #CostCurrent Start Date
100170002/1/2017
10180003/1/2017

 

1 ACCEPTED SOLUTION
dkay84_PowerBI
Microsoft Employee
Microsoft Employee

I wasn't following your description, but purely by looking at your expected result I suspect you can acheive this easily in the query editor.

 

You can "Group By" PSOW# and add two aggregations: SUM of Cost and MAX of Start Date.  See if that works.  I'm not 100% sure about the MAX of Start Date but try it and let us know

View solution in original post

5 REPLIES 5
dkay84_PowerBI
Microsoft Employee
Microsoft Employee

I wasn't following your description, but purely by looking at your expected result I suspect you can acheive this easily in the query editor.

 

You can "Group By" PSOW# and add two aggregations: SUM of Cost and MAX of Start Date.  See if that works.  I'm not 100% sure about the MAX of Start Date but try it and let us know

MAX function works with dates, so in this it will be ok.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

If I use Max or LastNonBlank how do I ensure my table is sorted properly where it always evaluates the highest number PCR # all the way down to the blank PCR #? For code example I'll use lastnonblank.  Basically I need to sort by PCR # before returning LastNonBlank.

 

Current Start Date =
LASTNONBLANK ( PSOW[Est Start date], 1 )

Not sure I follow you. Did you follow my steps? That will produce the result you showed

I edited my previous post as it looks like I left out a couple words 🙂  I chose to use a Measure using LastNonBlank instead of Max but assume both will work.  What I'd like to do within the code of the measure is ensure the data is sorted correctly so it always evaluates this highest PCR # first.  

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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