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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
ElliotK
Helper I
Helper I

Earlier TaskCreationDate

Hello,

 

Trying to capture the TaskCreationDate from row 5 and display it on row 6.  In essence, whenever there is a TaskPositionID 4, followed by and TaskPositionID 3, I wish to see the TaskCreationDate on the completed line. The TaskSTatusID must remain the same, as will the eFileID. The TaskID is unique. I have tried to do this using a new column but PBI does not like the syntax. 

 

TaskIDTaskGroupIDTaskStatusIDTaskStatusStartDateEndDateTaskPositionIDTaskPositioneFileIDTaskCreationDate
174631Processing28/07/2022NULL2In Progress3813/07/2022 07:00
182031Processing28/07/2022NULL2In Progress3813/07/2022 08:00
181331Processing28/07/2022NULL2In Progress3813/07/2022 09:00
275731Processing28/07/2022NULL4Queried Technician3813/07/2022 10:01
203261Processing28/07/202229/07/20223Completed3813/07/2022 12:00

 

I have tried using the below syntax:

 

EARLY = CALCULATE(MAX('vw_Tasks_all'[TaskCreationDate]),
FILTER(vw_Tasks_all,'vw_Tasks_all'[eFileID]=EARLIER('vw_tasks_all'[eFileID])
&&
'vw_Tasks_All'[TaskCreationDate]>EARLIER('vw_tasks_all'[TaskCreationDate])
&&
vw_Tasks_all,'vw_Tasks_all'[TaskStatusID]=EARLIER('vw_tasks_all'[TaskStatusID]
&&
'vw_Tasks_all'[TaskPositionID]=3
&&
EARLIER('vw_Tasks_All'[TaskPositionID])=4
)
)

 

Any help offered appreciated. 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @ElliotK ,

Here are the steps you can follow:

1. In Power query. Add Column – Index Column – From 1.

vyangliumsft_0-1660868378221.png

2. Create calculated column.

EARLY1 =
var _1=    SUMX(FILTER(ALL(vw_Tasks_all),'vw_Tasks_all'[TaskStatusID]=EARLIER('vw_Tasks_all'[TaskStatusID])&&  'vw_Tasks_all'[eFileID]=EARLIER('vw_Tasks_all'[eFileID])&&'vw_Tasks_all'[Index]=EARLIER('vw_Tasks_all'[Index])),[TaskPositionID])
var _2=    SUMX(FILTER(ALL(vw_Tasks_all),'vw_Tasks_all'[TaskStatusID]=EARLIER('vw_Tasks_all'[TaskStatusID])&& 'vw_Tasks_all'[eFileID]=EARLIER('vw_Tasks_all'[eFileID])&&'vw_Tasks_all'[Index]=EARLIER('vw_Tasks_all'[Index])-1),[TaskPositionID])
    return
IF(
    _1=3&&_2=4,
MAXX(FILTER(ALL(vw_Tasks_all),'vw_Tasks_all'[TaskStatusID]=EARLIER('vw_Tasks_all'[TaskStatusID])&& 'vw_Tasks_all'[eFileID]=EARLIER('vw_Tasks_all'[eFileID])&&'vw_Tasks_all'[Index]=EARLIER('vw_Tasks_all'[Index])-1),[TaskCreationDate]),
    [TaskCreationDate])

3. Result:

vyangliumsft_1-1660868378226.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi  @ElliotK ,

Here are the steps you can follow:

1. In Power query. Add Column – Index Column – From 1.

vyangliumsft_0-1660868378221.png

2. Create calculated column.

EARLY1 =
var _1=    SUMX(FILTER(ALL(vw_Tasks_all),'vw_Tasks_all'[TaskStatusID]=EARLIER('vw_Tasks_all'[TaskStatusID])&&  'vw_Tasks_all'[eFileID]=EARLIER('vw_Tasks_all'[eFileID])&&'vw_Tasks_all'[Index]=EARLIER('vw_Tasks_all'[Index])),[TaskPositionID])
var _2=    SUMX(FILTER(ALL(vw_Tasks_all),'vw_Tasks_all'[TaskStatusID]=EARLIER('vw_Tasks_all'[TaskStatusID])&& 'vw_Tasks_all'[eFileID]=EARLIER('vw_Tasks_all'[eFileID])&&'vw_Tasks_all'[Index]=EARLIER('vw_Tasks_all'[Index])-1),[TaskPositionID])
    return
IF(
    _1=3&&_2=4,
MAXX(FILTER(ALL(vw_Tasks_all),'vw_Tasks_all'[TaskStatusID]=EARLIER('vw_Tasks_all'[TaskStatusID])&& 'vw_Tasks_all'[eFileID]=EARLIER('vw_Tasks_all'[eFileID])&&'vw_Tasks_all'[Index]=EARLIER('vw_Tasks_all'[Index])-1),[TaskCreationDate]),
    [TaskCreationDate])

3. Result:

vyangliumsft_1-1660868378226.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

ElliotK
Helper I
Helper I

Tried stripping this down to a simplified version :

 

EARLY2 = CALCULATE(MAX('vw_Tasks_all'[TaskCreationDate]),
FILTER(vw_Tasks_all,'vw_Tasks_all'[eFileID]=EARLIER('vw_Tasks_all'[eFileID]

)))
 
Getting the below error for the column: EALIER/EARLIEST referes to an earlier row context which doesn't exist.
amitchandak
Super User
Super User

@ElliotK , Can you share the expected output column?

 

This can give dattime of last task id

 

 

EARLY = CALCULATE(MAX('vw_Tasks_all'[TaskCreationDate]),
FILTER(vw_Tasks_all,'vw_Tasks_all'[eFileID]=EARLIER('vw_tasks_all'[eFileID])
&&
'vw_Tasks_All'[TaskCreationDate]>EARLIER('vw_tasks_all'[TaskCreationDate])
&&
vw_Tasks_all,'vw_Tasks_all'[TaskID]< EARLIER('vw_tasks_all'[TaskID]
) ))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak,

 

Sure. I am receiving an error stating: Too many arguments were passed to the FILTER function. The maximum argument count for function is 2. 

 

FYI. I am hoping to see the TaskCreationDate (13/07/2022 10:01) in row ID 2032.

 

Forgot to mention, this is direct query. Not sure if that matters? 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.