Cognos Report Keyword Search -
i need provide keyword search option in cognos report. have 4 text box prompts keywords. need solution filter details field based on 4 keywords entered. filter expression tried is:
if (?p_details1? not null) ( if (?p_details2? not null) ( if (?p_details3? not null) ( if (?p_details4? not null) (upper([details]) contains (upper(?p_details1?)) or upper([details]) contains (upper(?p_details2?)) or upper([details]) contains (upper(?p_details3?)) or upper([details]) contains (upper(?p_details4?))) else (upper([details]) contains (upper(?p_details1?)) or upper([details]) contains (upper(?p_details2?)) or upper([details]) contains (upper(?p_details3?))) ) else (upper([details]) contains (upper(?p_details1?)) or upper([details]) contains (upper(?p_details2?))) ) else (upper([details]) contains (upper(?p_details1?))) ) else (1=1)
if 1 of text box prompts null report returns records. appears ignoring if statements. works if text box prompts have data.
cheers.
this filter should work you:
(?p_details1? not null , upper([details]) contains (upper(?p_details1?))) or (?p_details2? not null , upper([details]) contains (upper(?p_details2?))) or (?p_details3? not null , upper([details]) contains (upper(?p_details3?))) or (?p_details4? not null , upper([details]) contains (upper(?p_details4?))) or (?p_details1? null , ?p_details2? null , ?p_details3? null , ?p_details4? null)
it might helpful think of filter test cognos apply every row. either keep row (true) or discard (false). relational database sources, doesn't work way internally in effect.
the filter first checks see if first prompt has value , [details] data item contains prompt value. if does, includes row , moves on next row. if doesn't, moves next part of or statement tests second prompt. if second prompt has value , [details] data item contains prompt value row kept , moves on next row. repeated 4 of parameters.
if none of expressions return true , last part evaluated. expression checks see if prompts null. if so, rows returned.
Comments
Post a Comment