Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

tdiwanji
New Contributor

How can I get aggregated value ?

custIDRatingSales
111AA1000
222AAA500
333A30
444BBB50
555BB100
666B1000

I want the resultant table as below.

RatingTotal Sales
A - AAA1530
B - BBB1150

A-AAA includes A, AA and AAA ratings.

B-BBB includes B, BB, and BBB ratings.

Kindly help.

7 Replies
thakkarrahul01
Contributor

Re: How can I get aggregated value ?

‌HI Tapan,

In script you can add a new column in table which have condition on Rating column something like -

If   Rating like ‘A*’ then  ‘A-AAA’

     if  Rating like ‘B*’ then ‘B-BBB’

Use this field as a dimension and sum of sales should give you results.

Regards,

Rahul

tdiwanji
New Contributor

Re: How can I get aggregated value ?

Does Qlik Sense provide any way to create measures using such dimensions instead of loading it through table all the time ?

OR creating a temp table to store such values ?

thakkarrahul01
Contributor

Re: How can I get aggregated value ?

‌You can create calculated dimension in chart as well with if conditions but would recommend pre calculating in script.

Downside would be that you will require to know this logic beforehand.

mdmukramali
Valued Contributor III

Re: How can I get aggregated value ?

Hi,

If you have only a few Ratings then you can write Condition on Dimensions to get the result.

Like :

Dimesion:

=if(Left(Rating,1)='A','A-AAA',

                    if(Left(Rating,1)='B','B-BBB'))


or

=PICK(Match(Rating,'A','AA','AAA','B','BB','BBB'),'A-AAA','A-AAA','A-AAA','B-BBB','B-BBB','B-BBB')


suppose in your real data if you have many Rating then it will be better to create a condition in the Scripting Level or else you can create a Line line table to group them.

like:

Load * inline

[

Rating,Rating_Group

A,A-AAA

AA,A-AAA

AAA,A-AAA

B,B-BBB

BB,B-BBB

BBB,B-BBB

]

;

Use Rating Group as Dimension and Expression as Sum(Sales)

Thanks,

Mohammed Mukram

Partner
Partner

Re: How can I get aggregated value ?

Hi,

You can use the below expression as your dimension and use sum(Sales) as you measure

pick(WildMatch(Rating,'A*','B*'),'B-BBBB','A-AAA')

tdiwanji
New Contributor

Re: How can I get aggregated value ?

Thanks..  I will try and confirm.

Highlighted
haupenthals
New Contributor III

Re: How can I get aggregated value ?

Try this:

TAB:
LOAD * INLINE [
F1, Rating, Sales
111, AA, 1000
222, AAA, 500
333, A, 30
444, BBB, 50
555, BB, 100
666, B, 1000
]
;




Left Join (TAB)
LOAD Rating,
if(wildmatch(Rating, 'A*'),'A-AAA', if(wildmatch(Rating, 'B*'), 'B-BBB', Null())) as New_Rating
Resident TAB;

Then you can create a simple table Chart: