TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Shafiqq Aziz
NA
54
12.2k
Convert Formula from Excel to SQL Server Format
Apr 5 2018 1:48 AM
Hi guys, i need help to convert excel formula to sql server syntax.
Here's the formula
=IF(
([@[Net Available Stock Quantity]]+[@Subcon]+[@[In Progress WIP]]+
IFERROR([@[Raw Material In Store]]/[@[Demand Material]],0)+
IFERROR([@[Outstanding Raw Material]]/[@[Demand Material]],0)+
[@[Outstanding WIP]])
>
[@[Maximun Stock]],
([@[Net Available Stock Quantity]]+[@Subcon]+[@[In Progress WIP]]+
IFERROR([@[Raw Material In Store]]/[@[Demand Material]],0)+
IFERROR([@[Outstanding Raw Material]]/[@[Demand Material]],0)+
[@[Outstanding WIP]]-[@[Maximun Stock]]),
IF(([@[Net Available Stock Quantity]]+[@Subcon]+[@[In Progress WIP]]+
IFERROR([@[Raw Material In Store]]/[@[Demand Material]],0)+
IFERROR([@[Outstanding Raw Material]]/[@[Demand Material]],0)+[@[Outstanding WIP]])
<
[@[Minimum Stock]],
-[@[Minimum Stock]]+([@[Net Available Stock Quantity]]+[@Subcon]+[@[In Progress WIP]]+
IFERROR([@[Raw Material In Store]]/[@[Demand Material]],0)+
IFERROR([@[Outstanding Raw Material]]/[@[Demand Material]],0)+[@[Outstanding WIP]]),0)
)
Here's what i've done :
SELECT
[Item
No
]
CASE
WHEN
(
[Net Available Stock Quantity]+Subcon+[
In
Progress WIP]+
CASE
(
WHEN
([Raw Material
In
Store]
AND
[Demand Material] != 0
THEN
[Raw Material
In
Store]/[Demand Material]
ELSE
0) +
WHEN
([Outstanding Raw Material]
AND
[Demand Material] != 0
THEN
[Outstanding Raw Material]/[Demand Material]
ELSE
0) +
[
In
Progress WIP]) > [Maximum Stock])
THEN
(
[Net Available Stock Quantity]+Subcon+[
In
Progress WIP]+
CASE
(
WHEN
([Raw Material
In
Store]
AND
[Demand Material] != 0
THEN
[Raw Material
In
Store]/[Demand Material]
ELSE
0) +
WHEN
([Outstanding Raw Material]
AND
[Demand Material] != 0
THEN
[Outstanding Raw Material]/[Demand Material]
ELSE
0) +
[
In
Progress WIP]) - [Maximum Stock])
ELSE
(
[Net Available Stock Quantity]+Subcon+[
In
Progress WIP]+
CASE
(
WHEN
([Raw Material
In
Store]
AND
[Demand Material] != 0
THEN
[Raw Material
In
Store]/[Demand Material]
ELSE
0) +
WHEN
([Outstanding Raw Material]
AND
[Demand Material] != 0
THEN
[Outstanding Raw Material]/[Demand Material]
ELSE
0) +
[
In
Progress WIP] < [Minimum Stock])
THEN
(
[Minimum Stock]+[Net Available Stock Quantity]+Subcon+[Outstanding WIP]+
CASE
(
WHEN
([Raw Material
In
Store]
AND
[Demand Material] != 0
THEN
[Raw Material
In
Store]/[Demand Material]
ELSE
0) +
WHEN
([Outstanding Raw Material]
AND
[Demand Material] != 0
THEN
[Outstanding Raw material]/[Demand Material]
ELSE
0) +
[Outstanding WIP])
)
END
AS
[Final Stock Over
Max
]
I don't know where and what is wrong. Tried paste to sql query, certain part higlighted as Incorrect syntax. Google syntax of SELECT CASE WHEN, i think it's all good.
Please help me
Reply
Answers (
1
)
what is toad data modeler ?
Data Sync between more than two SQL Server