mercredi 21 septembre 2016

Gantt chart divided on two parts in Tableau

I should create Gantt chart that have 4 status inside: process, pending, success and error. I have made chart and it is fine. But new request is that I should have for example for process two parts: waiting time and running time. I don't know how to combine it cause I have mix of date function and string.

This is my status:

 IF [Progress] == -1 THEN
"Pending"
ELSEIF [Progress] < 100 THEN
"In Process"
ELSEIF [Finish Code] == 0 THEN
"Success"
ELSE
"Error"
END

This is my waiting time:

IF [Job status] = "Pending" THEN 
(DATEDIFF('second',[Created At],NOW()))
ELSEIF [Job status] = "In Process" THEN 
    (DATEDIFF('second',[Created At],[Started At]))
ELSE
    (DATEDIFF('second',[Created At],[Started At]))
END

This is my running time:

IF ISNULL([Started At]) THEN
 DATEDIFF('second', [Created At], NOW())
 ELSEIF ISNULL([Completed At]) THEN
  DATEDIFF('second', [Started At], NOW())
ELSE
  DATEDIFF('second', [Started At], [Completed At])
 END

And I attempted to put it all together:

 IF [Job status 2] = "Pending" AND NOT ISNULL(DATEDIFF('second',[Created      At],NOW())) THEN "Pending" 

 ELSEIF ([Job status 2] = "In Process" and NOT ISNULL(DATEDIFF('second', [Created At],[Started At]))) then "In Process WT"
 ELSEIF ([Job status 2] = "In Process" AND ISNULL([Completed At]) AND NOT   ISNULL(DATEDIFF('second', [Started At], NOW()))) then "In Process RT"

 ELSEIF ([Job status 2] = "Success" and (NOT ISNULL(DATEDIFF('second',[Created At],[Started At])) AND ISNULL(DATEDIFF('second',[Started At],[Completed At])))) then "Success WT" 
 ELSEIF ([Job status 2] = "Success" and (DATEDIFF('second',[Started At],[Completed At]))>=0) then "Success RT"

 ELSE "Error"
 END

But this is only provide me output for: Pending, Success RT and In process WT, because of else if loop.

Can anyone help me with this? How to make this condition different?

BR, Maria

Aucun commentaire:

Enregistrer un commentaire