Forum Discussion

legendsfan's avatar
legendsfan
Frequent Visitor
9 years ago
Solved

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

 

  • 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

5 Replies

  • dkay84_PowerBI's avatar
    dkay84_PowerBI
    Icon for Microsoft Employee rankMicrosoft 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

    • parry2k's avatar
      parry2k
      Icon for Super User rankSuper User

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

      • legendsfan's avatar
        legendsfan
        Frequent Visitor

        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 )