Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Grouping data in cyclic dimension group

Hi everyone ,

I am new to qlikview and I am facing a problem described below:

I have a cyclic group on dimensions (Category , Sub-Category) . In my chart I have two expression one is sale and other is Total sale.

Sale                : Sum(Sale)

Total Sale        : Sum({1} Total Sale)

I want following result when I select 'A' and Category is on X-Axis:

Sale(A) : 3

Total Sale : 78

But when Sub-Category is on X-Axis it should group data to sub-category:

Sale(a) : 1

Sale(b) : 2

Total Sale(a) : 36

Total Sale(b) : 42

Here in place of total sale it gives me 78 , may be it is not grouping data to sub - category so how can I do that in my expression?

Category     Sub-Category     Sale

=========================

A                        a                  1

A                        b                  2

B                        a                  3

B                        b                  4

C                        a                  5

C                        b                  6

D                        a                  7

D                        b                  8

E                        a                  9

E                        b                  10

F                        a                  11

F                        b                  12

==========================

Any help will be highly appreciated.

1 Solution

Accepted Solutions
oleg_orlov
Creator
Creator

Try this:

First: Sum (Sale)

Second: Aggr (Sum ({$<Category=, SubCategory=>} TOTAL <SubCategory> Sale), CategoryGroup)

View solution in original post

10 Replies
oleg_orlov
Creator
Creator

Hi! You should try Aggr function.

aggr ([ distinct | nodistinct ] [{set_expression}]expression {, dimension})

Dimension will be name of cyclic group, expression will be Sum.

Not applicable
Author

Thanks for the reply I have edited expression like this

Aggr(({1} Total Sum(Sale)) ,Sub-Category)

but it gives me 78 , if I remove "{1} Total" from above expression then it gives me 1,2 except 36,42

oleg_orlov
Creator
Creator

Try this:

First: Sum (Sale)

Second: Aggr (Sum ({$<Category=, SubCategory=>} TOTAL <SubCategory> Sale), CategoryGroup)

Not applicable
Author

Thanks a lot Oleg , It worked fine for me now , but can you please elaborate how this works?

kumarnatarajan
Partner - Specialist
Partner - Specialist

Hi,

Try this one

Ex: Sum({1}TOTAL Sales)

Find the attached file

Not applicable
Author

Hi kumar ,

I am using trial of Personal edition so I am unable to open this file.

kumarnatarajan
Partner - Specialist
Partner - Specialist

Hi,

Try this

Ex: Sum({1}TOTAL Sales)

Not applicable
Author

Hi Kumar ,

     I already have used this expression , see my question , but the problem was that it sums whole data it was not grouping data to sub-category , But answer posted by oleg resolved my problem ,

Thanks.

oleg_orlov
Creator
Creator

Aggr (Sum ({$<Category=>} TOTAL <SubCategory> Sale), CategoryGroup)

Aggr function works like GROUP BY. So Sum calculates for each value of Category or SubCategory.

QlikView Help for TOTAL: "The total qualifier may be followed by a list of one or more field names within angle brackets. These field names should be a subset of the chart dimension variables. In this case the calculation will be made disregarding all chart dimension variables except those listed, i.e. one value will be returned for each combination of field values in the listed dimension fields."

And {$<Category=>} means that we reset current selected values for Category. (SubCategory we don't have to reset).