COGNOiSe.com - The IBM Cognos Community

Legacy Business Intelligence => COGNOS ReportNet => Topic started by: mallika on 08 Oct 2005 12:25:00 PM

Title: [Solved] Combining two queries into one
Post by: mallika on 08 Oct 2005 12:25:00 PM
in a table I have the following sample data:

accountÃ,  Ã,  Ã,  Ã,  Ã,  Ã,  product grpÃ,  Ã,  Ã,  Ã,  Ã, ProductÃ,  Ã,  Ã,  Ã, promo. idÃ,  Ã,  Ã,  Ã,  Ã,  Ã,  amt. in $Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, Cost in $

acct 1Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, GrpÃ,  1Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, aÃ,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  0001Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  115Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, 200
acct 1Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, GrpÃ,  1Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, bÃ,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  0001Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  115Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, 100
acct 1Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, GrpÃ,  1Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, cÃ,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  0001Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, 115Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, 200
acct 1Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, GrpÃ,  2Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, dÃ,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  0002Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  100Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, 100

acct 2Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, GrpÃ,  1Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, aÃ,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  0001Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, 100Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  150
acct 2Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, Grp 1Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  bÃ,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  0001Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, 100Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  110

promo_id is like a promotion for a given product. Unfortunately in the table however, amt of 115 repeats three times for the same promo_id due to some logistic problems while importing data into the table. It should actually be


accountÃ,  Ã,  Ã,  Ã,  Ã,  Ã,  product grpÃ,  Ã,  Ã,  Ã,  Ã, ProductÃ,  Ã,  Ã,  Ã, promo.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Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  0002Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  100Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  100

acct 2Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, GrpÃ,  1Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, aÃ,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  0001Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, 100Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  150
acct 2Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, Grp 1Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  bÃ,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  0001Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  0Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  110

however assuming we do not have an option to change this in the table

I have to generate a report that agregate the measures at the account level:

accountÃ,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, amt in $Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Cost in $

acct 1Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  215 (not 445)Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  600
acctÃ,  2Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, 100 (not 200)Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  260



The rollup criteria is different for the two columns.Ã,  rollup criteria for amt in $ isÃ, 
Ã,  Ã, 
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  total(distinct [amt in $] for promo_id)


while rollup criteria for Cost in $ is by default the auto_group and summarise at account levell

The problem is that i cannot do the first expression without including promo_id in the tabular data, but if I do, then I cant rollup the cost in $ to the account level.

If I had the option to use create seperate lists for each measure, that would solve my problem, but unfortunately the requirement is to create one list report.

I hope my question is clear. Can anyone please suggest a workaround.


Thanks
Title: Re: combining two queries into one
Post by: mallika on 08 Oct 2005 12:30:57 PM
I am sorry the previous post was illegible i am reposting :


in a table I have the following sample data:

account    product grp         Product       promo. id            amt. in $       Cost in $

acct 1       Grp  1                     a                    0001                  115          200
acct 1       Grp  1                     b                    0001                  115          100
acct 1       Grp  1                     c                    0001                   115          200
acct 1       Grp  2                     d                    0002                  100          100

acct 2       Grp  1                     a                    0001                   100         150
acct 2       Grp 1                      b                    0001                   100         110

promo_id is like a promotion for a given product. Unfortunately in the table however, amt of 115 repeats three times for the same promo_id due to some logistic problems while importing data into the table. It should actually be


account     product grp         Product       promo. id            amt. in $     Cost in $

acct 1        Grp  1                     a                    0001                  115         200
acct 1        Grp  1                     b                    0001                    0           100
acct 1        Grp  1                     c                    0001                     0           200
acct 1        Grp  2                     d                    0002                    100       100

acct 2        Grp  1                     a                    0001                   100        150
acct 2        Grp 1                      b                    0001                      0         110

however assuming we do not have an option to change this in the table

I have to generate a report that agregate the measures at the account level:

account                       amt in $                              Cost in $

acct 1                      215 (not 445)                            600
acct  2                     100 (not 200)                            260



The rollup criteria is different for the two columns.  rollup criteria for amt in $ is
   
                                      total(distinct [amt in $] for promo_id)


while rollup criteria for Cost in $ is by default the auto_group and summarise at account levell

The problem is that i cannot do the first expression without including promo_id in the tabular data, but if I do, then I cant rollup the cost in $ to the account level.

If I had the option to use create seperate lists for each measure, that would solve my problem, but unfortunately the requirement is to create one list report.

I hope my question is clear. Can anyone please suggest a workaround.


Thanks
Title: Re: combining two queries into one
Post by: sir_jeroen on 09 Oct 2005 04:34:46 PM
Have you tried AVG(amt. in $ ) or min(amt. in $ ) or by grouping on [amt. in $] ?


Btw... next time modify the old topic instead of placing a new one...
Title: Re: combining two queries into one
Post by: kattaviz on 10 Oct 2005 04:27:03 AM
Hi,

Can you create two calculated query items (with some conditions), which will be rolledup as per your requirements, and then use those calculated query items in the report.


Thanks & Regards
Satish Kumar Katta
Title: Re: combining two queries into one
Post by: sir_jeroen on 10 Oct 2005 01:46:41 PM
Little reminder: close the topic if it's been solved/closed (see board rules)
Title: Re: combining two queries into one
Post by: mallika on 11 Oct 2005 12:29:34 PM
sorry for the delay in replying... i couldn't do this at the reportnet level, had to go in down and dirty at the database level and modify the data there.

Thanks for all the help.

Please consider this topic SOLVED