简体   繁体   中英

Cognos Report total values with same date

I'm building a report in IBM Cognos report studio.

A set of data looks like this: including location name, item name , item number , and days in inventory.

id     date       type      hours
1   10/27/2021    work       7
1   10/27/2021    overtime   1
1   10/24/2021    work       7
1   10/26/2021    work       7 

I use total to sum the hours for the same date

total ([Hours] for [Date],[ID])

It returns:

id     date       type      hours
1   10/27/2021    work       8
1   10/27/2021    overtime   8
1   10/24/2021    work       7
1   10/26/2021    work       7 

Then I tried a count and running count. then set count = 1 in the filter. Set object aggregate after. Data returns:

id     date       type      hours  count
1   10/27/2021    work       1      1
1   10/27/2021    overtime   1      2
1   10/24/2021    work       1      1
1   10/26/2021    work       1      1

what I need:

id     date       type      hours 
1   10/27/2021    work       8
1   10/24/2021    work       7
1   10/26/2021    work       7 

Thanks for your help!

The requirement is still a bit unclear, but if I understand it correctly, the query needs these data items:

Name Expression Aggregation
id [id] none
date [date] none
type 'work' none
hours [hours] Total

Then add a filter with this expression:

[type] in ('work', 'overtime')

Include any values for [type] that you consider "work".

Alternatively, because your comments indicate your sample input and desired output are incomplete...

Name Expression Aggregation
id [id] none
date [date] none
type case when [type] in ('work', 'overtime') then 'work' else [type] end none
hours [hours] Total

...without the filter.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM