Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
tdiwanji
Contributor
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
Creator
Creator

‌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
Contributor
Contributor
Author

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
Creator
Creator

‌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
Specialist III
Specialist III

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

vishweshwarisun
Partner - Creator
Partner - Creator

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
Contributor
Contributor
Author

Thanks..  I will try and confirm.

haupenthals
Contributor III
Contributor III

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: