Forum Discussion
Write code in easier way
- 7 years ago
Hi Albin,
This is a calculated column by the looks of it.
I would suggest declaring some variables and using the SWITCH function.
Here is one way of doing it where I have stored almost every column value and constant in a variable. The SWITCH function replaces most of the nested IFs. I have also simplified the expression of the logical tests.
SLA FORM OTC = VAR P = 'SNOW(sn_sm_finance_request)'[priority] VAR AG = 'SNOW(sn_sm_finance_request)'[assignment_group] VAR Spain = "FSM OTC Front Office Spain" VAR Shared = "FSM OTC Shared Service Center" VAR Spain_Shared = { Spain; Shared } VAR P1 = "1 - Critical" VAR P2 = "2 - High" VAR P3 = "3 - Moderate" VAR P4 = "4 - Low" VAR PBlank = "" RETURN IF ( AG IN Spain_Shared; SWITCH (
P;
P1; "0.4";
P2; "0.8";
P3; "3";
P4; "3";
PBlank; "3";
""
); "" )Can you confirm this still works?
Regards,
Owen
Hi Albin,
This is a calculated column by the looks of it.
I would suggest declaring some variables and using the SWITCH function.
Here is one way of doing it where I have stored almost every column value and constant in a variable. The SWITCH function replaces most of the nested IFs. I have also simplified the expression of the logical tests.
SLA FORM OTC =
VAR P = 'SNOW(sn_sm_finance_request)'[priority]
VAR AG = 'SNOW(sn_sm_finance_request)'[assignment_group]
VAR Spain = "FSM OTC Front Office Spain"
VAR Shared = "FSM OTC Shared Service Center"
VAR Spain_Shared = { Spain; Shared }
VAR P1 = "1 - Critical"
VAR P2 = "2 - High"
VAR P3 = "3 - Moderate"
VAR P4 = "4 - Low"
VAR PBlank = ""
RETURN
IF (
AG IN Spain_Shared;
SWITCH (
P;
P1; "0.4";
P2; "0.8";
P3; "3";
P4; "3";
PBlank; "3";
""
);
""
)Can you confirm this still works?
Regards,
Owen
Hi,
Thank you very much!
It work great.
Regards
Albin