Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Problem with Variable

Hi All,

New to QV & slowly getting to grips with the syntax for QV expressions and have come across a problem using variables.

I have a variable defined: v_subsect where the value is SUBSECTION_DESC (without an equals) using this in a straight table with a dollar sign $(v_subsect) produces the correct result in that for each line on the table (representing a product) the correct Sub-Section is diplayed.

I have come up against issues trying to use the variable in a set analysis within the same straight table.

for example to give the total revenue for the sub-section a product belongs to I tried:

sum({<SUBSECTION_DESC=$(v_subsect)>}revenue)

OR

sum({<SUBSECTION_DESC={$(v_subsect)}>}revenue)

neither of which produced a value at all.

Does anybody have any ideas as to where I am going wrong??

Thanks

PS - whilst I understand sharing the QV would be helpful, unfortunately I cannot do so due to business restrictions!

1 Solution

Accepted Solutions
Not applicable
Author

=aggr(nodistinct sum(units)/sum(visits),range)

boom!

View solution in original post

16 Replies
Not applicable
Author

Hi Andrew,

Try this:

sum({<SUBSECTION_DESC={$(=v_subsect)}>}revenue)

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

     Try puting = in your variable declaration.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Not applicable
Author

Thanks Both - unfortunately I still get zero! which I know is not the correct answer (Since I can see the revenue for the product)

Not applicable
Author

Sum({$<SUBSECTION_DESC={$(=$var)}>}Revenue)

change $var

Not applicable
Author

Andrew, the variable returns a text? If so, try this:

sum({<SUBSECTION_DESC={$(=chr(39)&v_subsect&chr(39))}>}revenue)

Tammy_Milsom
Community Manager
Community Manager

try:

sum( TOTAL {<SUBSECTION_DESC={$(v_subsect)}>}revenue)

Not applicable
Author

Hi all - i am currently working with Andrew on this problem. I've attached a QVW with some dummy data which hopefully highlights the problem. Any ideas would be useful. Think we've tried most of them so far.

Not applicable
Author

Hi,

Change the expression as below:

 

sum({$<range={'$(v_Range)*'}>}units)

Not applicable
Author

alas no... That nets me the same result as:

sum({$<range>}units)

which is the total units for each product, rather than the total units for the range the product is in.

this also doesn't work

sum(all{$<range>}units)

as it totals all the ranges rather than all the products in the range.