Home > Forum > Tips&Tricks > Calculated Columns with If conditions

Calculated Columns with If conditions
0

Hello,

I need to set up two columns to calculate some KPIs for a report.
The first one will show the status based on Case statement and date difference:


(select
case when DATEDIFF(day,WFD_AttDateTime3,getdate()) >0 then 0
when DATEDIFF(day,WFD_AttDateTime3,getdate()) = 0 then 1
else 2
end)


The second column should pick the number of instances that have the conditions
DATEDIFF(day,WFD_AttDateTime3,getdate()) = 0
DATEDIFF(day,WFD_AttDateTime3,getdate()) < 0

and then divide by the number of total instances by month.
Since this is kind of dynamic, I think that putting this calculation on the report side would be best, but I don't know how to configure the second condition.

Any thoughts?
Thank you! :)

MVP

Hi Andreia,
could you specify a little bit more on how does the process look like?

Do we have multiple forms/workflows, what is currently in the report?
Maybe you could prepare some table/spreadsheet/screenshot of what you want to achieve?

Right now i'm seeing 3 columns there:
Signature, Status, KPI

Should the KPI be calculated like this?
(amount of instances(in process/workflow/doctype?) where DATEDIFF(day,WFD_AttDateTime3,getdate()) = 0) / (amount of all instances (in process/workflow/doctype?))
(amount of instances(in process/workflow/doctype?) where DATEDIFF(day,WFD_AttDateTime3,getdate()) < 0) / (amount of all instances (in process/workflow/doctype?))