Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
marcusbohman
Contributor II
Contributor II

Sum based on value and give new name

Hi,

I read a file with categories and values as below. There are many categories and some of them have very low value so I want to group them into a new category called "Others".

CategoryValue
1100
2200
3300
45
510

I want to make a static selection of which categories to sum as others so the output is as below.

CategoryValue
1100
2200
3300
Others15
1 Solution

Accepted Solutions
Or
MVP
MVP

Not a problem at all - just load the original category as well.

Load Category as OriginalCategory, if(Category = 4 or Category = 5, 'Others',Category) as Category, Value

View solution in original post

3 Replies
Or
MVP
MVP

If it's static, just use

Load if(Category = 4 or Category = 5, 'Others',Category) as Category, Value.

You can then use sum(Value) in your expressions.

If you need to do this at the script level, you can - you'll just have to GROUP BY the new category.

Likewise, if it's dynamic, you can still use the same thing -

Load if(Value < 20,'Others',Category) as Category, Value.

marcusbohman
Contributor II
Contributor II
Author

Thank you Or,

I would like to have the detailed level kept, for example in another sheet or so. Is it possible to do in the expression of a chart or table?

Should of course included that in my initial question. Sorry.

Or
MVP
MVP

Not a problem at all - just load the original category as well.

Load Category as OriginalCategory, if(Category = 4 or Category = 5, 'Others',Category) as Category, Value