Forum Discussion
CEllis
1 year agoResolver I
Adding MAX date before change in another column
Hi All, I am trying to add a table column to end up with the column called group below. Could anyone help please Primary Key Mark date Present Days Group 1 9/3/2024 2 1 9/17...
- 1 year ago
Group = IF( DATA[Present] = 2, VAR __dt = DATA[Mark date] VAR __gap = CALCULATE( MIN( DATA[Mark date] ), ALLEXCEPT( DATA, DATA[Primary Key] ), DATA[Present] = 0, DATA[Mark date] > __dt ) RETURN IF( ISBLANK( __gap ), CALCULATE( MAX( DATA[Mark date] ), ALLEXCEPT( DATA, DATA[Primary Key] ) ), CALCULATE( MAX( DATA[Mark date] ), ALLEXCEPT( DATA, DATA[Primary Key] ), DATA[Present] = 2, DATA[Mark date] < __gap ) ) )
DataNinja777
1 year agoSuper User
Hi CEllis ,
You can achieve this in Power Query by using the Fill Down feature. Here's how:
- Load your table into Power Query.
- Sort the Mark date column in ascending order.
- Select the Group column (which will initially have null values for gaps).
- Go to the Transform tab and click Fill Down to propagate the last valid date across rows until a new value is encountered.
This will fill the Group column with the reference dates for each continuous streak where Present = 2.
Best regards,