Cognos Report Studio If then or Case Statement that compares two different data types

StackOverflow https://stackoverflow.com/questions/19251352

  •  30-06-2022
  •  | 
  •  

質問

need to find my sales/returns by G/L account and G/L Group

I keep getting the following error

For this example im trying to break about my rebuilt sales both are in G/L Account 4100, but my rebuilt production sales have G/L Group PRODUCTION

I created a new query and put

if ([G/L Account] = 4100 and [G/L Group] = 'PRODUCTION') THEN ([Credit Amount] - [Debit Amount]) ELSE (0)

When i validate i get no errors, but when i try and view tabular data i get the following error An error occurred while performing operation 'sqlPrepareWithOptions' status='-126'.

I then tried this

[rebuilt_calc1]

[G/L Account] = 4100

[rebuilt_calc2]

CASE [rebuilt_calc1]
WHEN ([G/L Group] = 'PRODUCTION')
THEN ([Credit Amount] - [Debit Amount]) 
ELSE (0)
END

Is it because of tables im trying to compare? GL account and GL group? GL account is in [Distribution Management System].[Detail Ledger].[G/L Account] GL group is in [Distribution Management System].[Item G/L Group Master].[G/L Group]

Both are in the General Ledger Report Model

役に立ちましたか?

解決

Try

if (([G/L Account] = '4100') and ([G/L Group] = 'PRODUCTION')) THEN ([Credit Amount] - [Debit Amount]) ELSE (0)

Error 126 is sometimes caused by unsupported type conversion functions, so it might be worth wrapping you expressions in cast varchar(50) to test if that's the case. You can also check cogserver.log file in cognos_installation/logs folder, there should be detailed error description.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top