Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

brunolovatti
New Contributor II

Set Analysis Inside Variable with Parameter

Hi!

I have a variable vTest.

sum(
{
$<
Week={0},
Store={"*"}, //all stores
Item={$1}
>
}
total Sales
)

 

That works if I call like this:

$(vTest( "10-8 | ITEM X" ))

 

But does not work if I call like:

$(vTest( Item )) //where Item is the dimension and has the same value as "10-8 | ITEM X"

 

Tried a lot of combinations inside and outside the variable.

Outside:

$(vTest( $(=$(Chr(34) & Item& chr(34))) ))

$(vTest( "=$(Item)" ))

Inside:

sum(
{
$<
Week={0},
Store={"*"},
Item={$(='$1')} // and a lot of different combinations here
>
}
total Sales
)

 

Thank you!

 

Bruno

2 Solutions

Accepted Solutions
Partner
Partner

Re: Set Analysis Inside Variable with Parameter

I lied, you don't have to use AGGR for that one.

add a measure with Item and Store as dimensions then

Sum(Sales) as the first measure

Sum(Total <Item> Sales) as  the second Measure

Annotation 2019-07-26 145123.png

 

brunolovatti
New Contributor II

Re: Set Analysis Inside Variable with Parameter

It worked! 

Much simpler!

Sum(
{
$<
Week={ 0 }
>
}
total <Item> Sales
)

Thank you!!!

4 Replies
Partner
Partner

Re: Set Analysis Inside Variable with Parameter

It looks like you are trying to produce an expression that iterates over your Items and returns one row per item. The problem is that Set Analysis is interpreted only one time per object so the idea of putting a raw unaggregated field into a set analysis expression just does not work. please describe what you are trying to accomplish and we can help.

brunolovatti
New Contributor II

Re: Set Analysis Inside Variable with Parameter

I have this data

Store / Item / Sales / TOTAL

1 / A / 100

1 / B / 200

1 / C / 700

2 / A / 400

2 / B /600

I want to show total sales of the same items in all stores. 

1 / A / 100 / 500 

1 / B / 200 / 800

1 / C / 700 / 700

2 / A / 400 / 500

2 / B /600 / 800

 

Thank you!

Partner
Partner

Re: Set Analysis Inside Variable with Parameter

I lied, you don't have to use AGGR for that one.

add a measure with Item and Store as dimensions then

Sum(Sales) as the first measure

Sum(Total <Item> Sales) as  the second Measure

Annotation 2019-07-26 145123.png

 

brunolovatti
New Contributor II

Re: Set Analysis Inside Variable with Parameter

It worked! 

Much simpler!

Sum(
{
$<
Week={ 0 }
>
}
total <Item> Sales
)

Thank you!!!