Reputation: 49
I could do some help with the following formula. It currently works, but I want to add another part to it, which I cannot figure out how to do
The current formula is:
,CASE
WHEN
ABS(((t1.[RateAmount] - t1.[Amount]) / NULLIF (t1.[Amount],0) *100)) >1
OR ABS(((t2.volume - t1.TotalVolume) / NULLIF (t1.TotalVolume, 0) *100)) >5
THEN 1 ELSE 0
END AS OverallThresholdDifference
However I need to add in to the volume line, if over 5 AND a difference of 2000 and my mind has gone blank
Any help here would be really appreciated
Cheers
Upvotes: 0
Views: 38
Reputation: 237
WHERE t2.volume > 5 AND OverallThresholdDifference > 2000
TO get the OverallThresholdDifference
in your where clause, you will need to derive the entire query.
Upvotes: 0
Reputation: 31991
add another when
CASE
WHEN
ABS(((t1.[RateAmount] - t1.[Amount]) / NULLIF (t1.[Amount],0) *100)) >1
OR ABS(((t2.volume - t1.TotalVolume) / NULLIF (t1.TotalVolume, 0) *100)) >5
THEN 1
when
ABS(((t1.[RateAmount] - t1.[Amount]) / NULLIF (t1.[Amount],0) *100)) >5
and ABS(((t2.volume - t1.TotalVolume) / NULLIF (t1.TotalVolume, 0) *100)) >2000
THEN 2
ELSE 0
END AS OverallThresholdDifference
Upvotes: 1