As written in the Custom KPIs section's general information, you have to create the KPI's operand first. In this case, the operand name should be like:
TaskId_*YourTaskID* - If you want to create a Task time measurement
ProductiveTaskId_*YourTaskID* - If you want only the productive time spent on this task
TaskGroupId_*YourTaskGroupID* - If you want to create a Task group time measurement
ProductiveTaskGroupId_*YourTaskGroupID* - If you want only the productive time spent on this task group
ProjectId_*YourProjectID* - If you want to create a Project time measurement
ProductiveProjectId_*YourProjectID* - If you want only the productive time spent on this project
The rest of the KPI creation is the same what's in the general informations of the above mentioned page.