COGNOiSe.com - The IBM Cognos Community

IBM Cognos Analytics Platform => Cognos Analytics => Reporting => Topic started by: crazy_tech on 15 Mar 2024 10:09:58 AM

Title: If condition on prompt value
Post by: crazy_tech on 15 Mar 2024 10:09:58 AM
Hi i have a prompt prameter ?TypeofExpense? . I have another dataitem costofExpense .

Now if  ?TypeofExpense?= 'all' then costofExpense should give me cost for TypeofExpense='rent' else costofExpense for choosen TypeofExpense

As i have another dataitems (costs) also..i dont want to apply the filter for those data items
Title: Re: If condition on prompt value
Post by: cognostechie on 15 Mar 2024 03:49:39 PM
There is a way to do this although selecting 'All' from the prompt and showing values for 'rent' is not a bright idea ! You can add a static value to the Prompt for 'Rent'.

With what you have, you can use a Case statement in the data item costofExpense.

Case
  When ( ?TypeofExpense? = 'All' and [TypeofExpense] = 'rent' )
  Then ( costofExpense )
  Else ( 0 )
End

This presumes that [TypeofExpense] and [costofExpense] are two data items in the same query and the values of both will be present in each row.
Title: Re: If condition on prompt value
Post by: dougp on 18 Mar 2024 10:23:26 AM
Filters apply to queries, not data items.

Please provide sample inputs and desired outputs.