If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

Urgent - If Else Syntax

Started by Tina_345, 13 Jan 2022 01:48:53 PM

Previous topic - Next topic

Tina_345

hello,
   I am new in Cognos and trying to write one if then else.

    if([Qry_1].[FILE_DT]='9/30/2021') then (null) else ('9/30/2021')

i am getting syntax error.Could you please help?

Thanks

MFGF

Quote from: Tina_345 on 13 Jan 2022 01:48:53 PM
hello,
   I am new in Cognos and trying to write one if then else.

    if([Qry_1].[FILE_DT]='9/30/2021') then (null) else ('9/30/2021')

i am getting syntax error.Could you please help?

Thanks

Hi,

What is the error you are getting? Also, what is the datatype of the FILE_DT item - is it a date or a text string?

Where are you using this syntax? Is it in a query calculation? Filter expression? Layout calculation? Somewhere else?

Cheers!

MF.

Meep!

Tina_345

RSV-val 0034 Failed to Validate the variable string1 , with parsing error.
File_DT is date field.Oh wait a sec, I was trying to create a variable (I can see string or boolean but cannot see any related to date).
That might be causing  it.Is there any alternative?

I have a section on report, that are coming from singleton which I am trying to hide based on that variable condition.
If that variable is 9/30/2021, I want to hide certain section on this report page.

MFGF

Quote from: Tina_345 on 13 Jan 2022 02:40:20 PM
RSV-val 0034 Failed to Validate the variable string1 , with parsing error.
File_DT is date field.Oh wait a sec, I was trying to create a variable (I can see string or boolean but cannot see any related to date).
That might be causing  it.Is there any alternative?

I have a section on report, that are coming from singleton which I am trying to hide based on that variable condition.
If that variable is 9/30/2021, I want to hide certain section on this report page.

Hi,

So this is an expression in the definition of a variable? What variable type are you creating - a string variable or a boolean variable?

It sounds like a boolean variable would suit your requirements here. You could code the expression as

[Qry_1].[FILE_DT]='9/30/2021'

This would either return a TRUE result or a FALSE result in the boolean variable

Based on this variable being TRUE or FALSE you can then conditionally hide your object.

We still haven't got to the bottom of what datatype FILE_DT is, though. The above assumes it's a string of some sort. If it's a date, your expression would likely be

[Qry_1].[FILE_DT]=2021-09-30

Cheers!

MF.
Meep!