2

I have the following expression that works perfectly,

ISNULL(LateDays < 0 ? (DT_WSTR,30)OriginalTransactionAmount : "") ? "0"
: (LateDays < 0 ? (DT_WSTR,30)OriginalTransactionAmount : "")

The issue is that OriginalTransactionAmount is decimal, and I want the whole expression to be decimal. LateDats is (DT_14) integer. When I try to replace the DT_WSTR it gives me an error. Any clue on how I can make it decimal?

I am using this data in a report, and it's giving me a hard time, because the reporting tool is reading it as a text.

2
  • What happens when you put (DT_DECIMAL, 2) in front of each LateDays instance? Commented Feb 16, 2018 at 18:30
  • If I put decimal without changing the " " to a simple 0 it gives an error, because having the "" male the wole thing a string. Commented Feb 20, 2018 at 11:44

3 Answers 3

1

The Issue

The issue cause is that when using ? : conditional operators, both false and true result must have the same data type. So when using LateDays < 0 ? (DT_NUMERIC,18,2)OriginalTransactionAmount : "" there are one Decimal result and one String result, you can use the following expression instead of this *(replace "" with NULL(DT_NUMERIC):

ISNULL(LateDays < 0 ? (DT_NUMERIC,18,2)OriginalTransactionAmount : NULL(DT_NUMERIC,18,2)) ? (DT_NUMERIC,18,2)0 
: (LateDays < 0 ? (DT_NUMERIC,18,2)OriginalTransactionAmount : NULL(DT_NUMERIC,18,2))

Other Suggestion

Try using REPLACENULL() function

(REPLACENULL(LateDays,0) < 0) ? (DT_NUMERIC,18,2)OriginalTransactionAmount : (DT_NUMERIC,18,2) 0
Sign up to request clarification or add additional context in comments.

Comments

1

Break it into pieces:

isnull(LateDays) ? (DT_NUMERIC,18,2) 0 :

LateDays < 0 ? (DT_NUMERIC,18,2) OriginalTransactionAmount : (DT_NUMERIC,18,2) 0

LateDays is in the Boolean portion and is not a result. All results have to be the same data type.

Comments

1

I replaced the " " with "0". Then after that added a data conversion task and changed it to decimal and it works.

ISNULL(LateDays < 0 ? (DT_WSTR,30)OriginalTransactionAmount : "0") ? "0" 
: (LateDays < 0 ? (DT_WSTR,30)OriginalTransactionAmount : "0")

1 Comment

You have to accept this answer, even if it is yours. Also if other answer was helpful, it is good to up vote them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.