Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
psankepalli
Partner - Creator III
Partner - Creator III

Set Analysis

Hello Experts,

I have the following code,

Fact:

LOAD *

Inline

[

Key, Value

1,10

1,20

2,5

];

DIMENSION:

LOAD *

Inline

[

Key, Brand

1,ABC

2,ABC1

];

Exit Script;

My requirement is whenever I select ABC from Dimension, I need a value of both ABC + ABC1 value and

BRANDSUM(VALUE)
ABC35
ABC10

How to achieve this unique requirement? I don't mind to use any type of set Analysis.

I want to acheive this unique requirement.

Please help.

Thanks

PR

1 Solution

Accepted Solutions
settu_periasamy
Master III
Master III

May be something like attached

I tried with valuelist..

Capture.JPG

View solution in original post

12 Replies
Gysbert_Wassenaar

Use this script and use BRAND as chart dimension instead of Brand.

Fact:

LOAD *

Inline

[

Key, Value

1,10

1,20

2,5

];

DIMENSION:

LOAD *

Inline

[

Key, Brand, BRAND

1,ABC, ABC

2,ABC1, ABC

0,,ABC1

];


talk is cheap, supply exceeds demand
Gabriel
Partner - Specialist III
Partner - Specialist III

Hi,

Try this Set Analysis

=Sum( {$<Brand={"*ABC*"}>}Value)

psankepalli
Partner - Creator III
Partner - Creator III
Author

Hi Gysbert,

I cannot change the values in the script, this INLINE data is just sample of my Band data.

I have brands like this

ABC,

ABC1

ABC2

.

.

.

XYZ

XYZ1

XYZ2.. etc

I need show values at ABC & XYZ group level.

  

Brand Sum(Brand)
ABC30
ABC10
ABC20
XYZ40
XYZ10
XYZ20

Not sure how to address it.

Please help.

psankepalli
Partner - Creator III
Partner - Creator III
Author

Hi Gabriel,

Thank you for your reply,

I tried this one, but this is not fulfilling my requirement. Any other suggestion.

Thanks

PR

Not applicable

Ultimately this is a data cleansing issue more than a set analysis issue and if you will have many charts that use this logic you should look at cleaning the data in the load script if at all possible.  There is obviously two data values combined in the Brand field.

Having said that, this expression will do what you want. It adds up every value associated with the selected brand.

sum({1<Brand = {'$(=getFieldSelections(Brand))*'}>} Value)

maxgro
MVP
MVP

maybe with a calculated dim

=PurgeChar(Brand, '0123456789')

psankepalli
Partner - Creator III
Partner - Creator III
Author

Hi Max,

Thank you for your reply, unfortunately my data is not linke that, that's only for example. My data is as below


ABC

ABC-ASL

ABC-NBC

XYZ

XYZ-ASL

XYZ-NBC

XYZ-NML


IN THIS, I want to show all brands in straight table but sum of the ABC group values at ABC, and remaining ABC groups should be zero. Same for XYZ too.


Not sure how to solve this

Please advise

settu_periasamy
Master III
Master III

May be something like attached

I tried with valuelist..

Capture.JPG

PrashantSangle

Hi,

another solution can be

Test:

LOAD * INLINE [

    Dim, Sales

    ABC, 10

    ABC-ASL, 20

    ABC-NBC, 30

    XYZ, 20

    XYZ-ASL, 30

    XYZ-NBC, 40

    XYZ-NML, 50

];

JOIN

LOAD SubField(Dim,'-',1) as Dim,

sum(Sales) as TotalSales

Resident Test

Group by SubField(Dim,'-',1);

Then in front end

take straight table

Dimension -> Dim

Expression ->

1: Sum(Sales)

2: Sum(Total Sales)

If you don't required sum(Sales) then hide it in Presentation tab but don't remove it.

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂