I am attempting to translate a SQL CASE statement but am running into some problems and was hoping I could get a hand. Here is the statement:
,SUM(CASE WHEN [Gads].[GadsEventTypeCode] IN ('D1', 'D2', 'D3', 'DP', 'PD', 'DM', 'D4')
THEN [Allocation].[AllocatedEnergyMwh] ELSE 0 END /
CAST([Unit].[NetDependableCapacity] AS FLOAT)) AS Hrs_Derate
This is what I come up with but get “lost in translation”:
If [Gads].[GadsEventTypeCode] equals 'D1', 'D2', 'D3', 'DP', 'PD', 'DM', 'D4'
then Hrs_Derate equals the sum of:
[Allocation].[AllocatedEnergyMwh] / [Unit].[NetDependableCapacity]
else Hrs_Derate equals zero.
You have three elements that you need to translate:
(cond) ? trueval : falseval.Containsoperator which can check if an element is contained inside an array.System.Convert.Armed with these three translation rules, you would need something like this (untested):