Forum Discussion

zxl1031's avatar
zxl1031
Helper I
7 years ago

Find the most recent row based on multiple columns

Hello everyone,

 

I set up a working pbix file for this problem. Log.pbix

 

I am doing a log parsing on this table. The last column "Required in To Version" is the result I would like to get. Thanks in advance for any help.

 

The logic is:

1) For Issues same ID and FieldType = "Version", if Required or Not Required field value is "Required" when the Version value is xxx, then mark it as Yes;

e.g. for the second row, the Version V2 was set on 01-02, and this Issue #1 was set to be Required on 01-01, which means it is required on V2.  Then the result is Yes.

 

Not sure if I explained the logic clearly..... Thanks!

IDChangeTimeFieldTypeFromToRequired in To Version?
#12018-01-01 8amRequired or Not RequiredNot RequiredRequired 
#12018-01-02 9amVersionV1V2Yes
#12018-01-12 9amRequired or Not RequiredRequiredNot Required 
#12018-01-13 11amVersionV2V3No
#12018-01-14 10amRequired or Not RequiredNot RequiredRequired 
#12018-01-15 4pmVersionV3V4Yes

0

2 Replies

  • I think maybe we could help you better if you were to explain what you want more clearly, as it is hard to understand what you are after.

  • v-lili6-msft's avatar
    v-lili6-msft
    Community Support

    hi, zxl1031

    If your logic is simple to understand is that 

    For Issues same ID and FieldType = "Version", after ranking by ChangeTime for the same ID, the value of the previous row in column To is "Required" 

    then "Yes", and the value of the previous row in column To is "Not Required" then "No"?

     

    If so, you could do these as below:

    Step1:

    Add a group rank column

    group rank = RANKX(FILTER('Log','Log'[ID]=EARLIER('Log'[ID])),'Log'[ChangeTime],,ASC)

    Step2:

    Add the Required in To Version column

    Required in To Version = IF('Log'[FieldType]="Version",IF(CALCULATE(MAX('Log'[To]),FILTER('Log','Log'[group rank]=EARLIER('Log'[group rank])-1))="Required","Yes","No"))

    Result:

     

    If not your case, please explain what you want more clearly for your logic.

     

    Best Regards,

    Lin