bkpierce
asked on
SQL Reporting IIF help
I have a report in crystal that I'm trying to duplicate in SQL reporting. It displays various information about projects. One of the fields in the report is Expected Contract, depending on what contract type is this information can be found in 3 differnt fields.
The contract field type is JC00102.Contract_Type, it can have a value of 1,2, or 3.
The dollar amount is in the corresponding fields based on contract type
If contract_type =1 dollar amount is in JC00102.Expected_Contract
If contract_type =2 dollar amount is in JC00107.User_Defined_Dolla r_1
If contract_type =3 dollar amount is in JC00102.Contract_Max_Bill_ Amt
I have one table cell that I need to display the "Expected Contract" based on the information above. How can I do this in SQL Syntax? I'm pretty sure I need to use IIF but not 100% sure.
The contract field type is JC00102.Contract_Type, it can have a value of 1,2, or 3.
The dollar amount is in the corresponding fields based on contract type
If contract_type =1 dollar amount is in JC00102.Expected_Contract
If contract_type =2 dollar amount is in JC00107.User_Defined_Dolla
If contract_type =3 dollar amount is in JC00102.Contract_Max_Bill_
I have one table cell that I need to display the "Expected Contract" based on the information above. How can I do this in SQL Syntax? I'm pretty sure I need to use IIF but not 100% sure.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
In MS SQL use the following expression in your select statement:
SELECT CASE WHEN JC00102.Contract_Type=1 THEN JC00102.Expected_Contract
WHEN JC00102.Contract_Type=2 THEN JC00107.User_Defined_Doll ar_1
WHEN JC00102.Contract_Type=3 THEN JC00102.Contract_Max_Bill_ Amt
END
In Reporting services, use an IIF Statement similar to the following:
=IIF(Fields!contract_type. Value=1, Fields!Expected_Contract, IIF(Fields!contract_type.V alue=2, Fields!User_Defined_Dollar _1, Fields!Contract_Max_Bill_A mt))
This assumes that contract_type.Value will always return 1,2 or 3.
Hope this helps
Rob
SELECT CASE WHEN JC00102.Contract_Type=1 THEN JC00102.Expected_Contract
WHEN JC00102.Contract_Type=2 THEN JC00107.User_Defined_Doll
WHEN JC00102.Contract_Type=3 THEN JC00102.Contract_Max_Bill_
END
In Reporting services, use an IIF Statement similar to the following:
=IIF(Fields!contract_type.
This assumes that contract_type.Value will always return 1,2 or 3.
Hope this helps
Rob
ASKER
Using switch worked great, thanks for your hlep.
In the code below you may need to change the type to whatever you are using coming from your SP.
If you want to use the IIF you will need to nest them.
Let me know and I can get it to you.
Open in new window