Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
raju_insights
Partner - Creator III
Partner - Creator III

Set Analysis - How to pass a field value in set analysys

Hi Techies,

Here I have two tables:

Table1:

Snapshot_MonthProducts_Aggregate
DecA,B,C,D,E
NovB,C,D
OctA,F

 

Table2:

Snapshot_MonthProductsRatingsum
DecA100
DecB200
DecC300
DecD400
DecE100
NovA100
NovB200
NovC300
NovD400
NovE100
OctA100
OctB200
OctC300
OctD400
OctE100

 

In a straight table, Snapshot_month is the dimension, Count(Products) is the expression.

Here, I need to pass Products_Aggregate via set expression to filter the products.

For example:

This is how we need the set expression.

Snapshot_MonthExpression
DecCount({$<Product={'A,B,C,D,E'}>}Product)
NovCount({$<Product={'B,C,D'}>}Product)
OctCount({$<Product={'A,F'}>}Product)

 

Required Output:

Snapshot_MonthOutput
Dec5
Nov3
Oct2

 

Please let me know how to achieve this.

Labels (2)
1 Solution

Accepted Solutions
kaanerisen
Creator III
Creator III

OK then how about this 🙂

COUNT(IF(WildMatch(prodAgg,product&',*','*,'&product,'*,'&product&',*',product),product))

Untitled.png

Your required output is mentioned in your post is

Snapshot_MonthOutput
Dec5
Nov3
Oct2

 

But Oct should be 1 because there is only Product A data that match in table 1 in October.

If you want to use set analysis, You should create a uniqueID for month&product.

load AutoNumber(month&'|'&product) as key,* Inline [
month,product,value
Dec,A,100
Dec,B,200
Dec,C,300
Dec,D,400
Dec,E,100
Nov,A,100
Nov,B,200
Nov,C,300
Nov,D,400
Nov,E,100
Oct,A,100
Oct,B,200
Oct,C,300
Oct,D,400
Oct,E,100
]

Count({<key={"=WildMatch(prodAgg,product&',*','*,'&product,'*,'&product&',*',product)"}>}key)

 

Hope it helps.

View solution in original post

12 Replies
Channa
Specialist III
Specialist III

dont need set expression just do count of product

Channa
raju_insights
Partner - Creator III
Partner - Creator III
Author

Hi Channa,

Count of product will give me 5 for all the snapshot months. But the required output is :

Dec - 5

Nov - 3

Oct - 2

Channa
Specialist III
Specialist III

=Snapshot_Month&'_'&Count(product)

 

try

or

try to have resident table for Count(product) as CountProducts

then  

Snapshot_Month&'_'&CountProducts

 

Channa
raju_insights
Partner - Creator III
Partner - Creator III
Author

Hi Channa,

I mean to say that the 

Required Output:

Snapshot_MonthOutput
Dec5
Nov3
Oct2
pradosh_thakur
Master II
Master II

May be try this 

 

Dimension = Snapshot_Month

 

expression = substringcount(Products_Aggregate,',')+1

Learning never stops.
kaanerisen
Creator III
Creator III

Hi Raju,

How about this.

SubStringCount(VALUE,',')+1

Untitled.png

Hope it helps..

Channa
Specialist III
Specialist III

try this expression

 

IF ( Snapshot_Month='Dec',Count({$<Product={'A,B,C,D,E'}>}Product),if(Snapshot_Month= 'Nov',Count({$<Product={'B,C,D'}>}Product),IF(Snapshot_Month='Oct',Count({$<Product={'A,F'}>}Product))))

Channa
raju_insights
Partner - Creator III
Partner - Creator III
Author

Hi Channa,

Thanks. But your solution is hard coded. I want it to happen dynamically.

Channa
Specialist III
Specialist III

Bro 

for Nov you have A,B,C,D,E  in your date and you want to cont A,B,C we have to go like this only

 

Channa