reportcognoscognos-bi

Cognos Report Studio: How can I change the image displayed based on a query output?


Using Cognos Report Studio:

I have a query that returns two numbers, and based on those two numbers I need to display an up, down or straight arrow. Images stored in the server.

Here are my conditions:

If (num1 > num2) then (green arrow)
If (num1 < num2) then (red arrow)
If (num1 = num2) then (straight arrow)

I've tried using a string variable called vImage with the following condition:

case
   when (num1 > num2) then (GreenArrow.png)
   when (num1 < num2) then (RedArrow.png)
   when (num1 > num2) then (StraightArrow.png)
end

With num1 and num2 as query results. Those .png files are my list of answers.

On my report, I have the Image layout element with the URL Source Variable set to that Image variable.

When I Run HTML though, the report element returns blank.

I have tried selecting and un-selecting values in the URL source variable dialog, but nothing seems to be working.

Any advice?


Solution

  • Given the requirement is just up and down arrow I really would not bother with images at all. Simply copy the ascii arrow into the if clause. https://unicode-table.com/en/sets/arrow-symbols/#up-arrows. Once completed, use the conditional style to adjust the font color.

    case
       when (num1 > num2) then (▲)
       when (num1 < num2) then (▲)
       when (num1 > num2) then (▲)
    end