
Re: Set analysis with variables
Bill Markham Dec 13, 2016 6:40 AM (in response to John Griggs)Have you got missing bracket, maybe try something like this :
SUM({$<
MarketableOrOutsize = "",
[Size Bucket] = ""
>}
($(vMarketableWeight)/($(vMarketableWeight) + $(vOutsizeWeight))* 100
)
Also when you do $(vMarketableWeight)/($(vMarketableWeight) you are dividing $(vMarketableWeight) by itself and that will always return one  maybe a typo.

Re: Set analysis with variables
John Griggs Dec 13, 2016 6:57 AM (in response to Bill Markham )Hi Cheers for the reply,
The calc works fine on its own. It's only when there's set analysis it doesn't work...which is due to the sum or sum problem.
Brackets are OK (I've tested without the set analysis)  and the internal brackets means it doesn't divide by itself as it forces the addition first (the underlined bit)  it probably seems backward the way it's laid out, but it's necessary as the outsize and marketable weights are built up of many size bands...all of which are valid in their own right (so have to be sums when the user makes multiple record selections), but all off which only ever belong to one set  Marketable or Outsize.
I'm 99% sure it's the SUM at the beginning of the set analysis that's the problem....just don't know how to fix it.
$(vMarketableWeight)/($(vMarketableWeight) + $(vOutsizeWeight))* 100


Re: Set analysis with variables
Gysbert Wassenaar Dec 13, 2016 6:42 AM (in response to John Griggs)The expression in your variable contains aggregations: SUM(....). You then put an aggregation function into another aggregation: SUM(SUM(...)). That's nonsense unless you specify over which dimensions the inner sums should be aggregated. You need to use the aggr function to do that: SUM( AGGR( SUM(....) , DimA, DimB, ..., DimX)). See this document for more information: QlikView Technical Brief  AGGR.docx

Re: Set analysis with variables
John Griggs Dec 13, 2016 6:44 AM (in response to Gysbert Wassenaar )There are no inner dimensions? Like I've mentioned, the calculation works fine on its own  and with any selections made on any sheets.
I get that it's the sum or sum that's the problem....but not sure why I need to use the AGGR function to fix?

Re: Set analysis with variables
Gysbert Wassenaar Dec 13, 2016 7:26 AM (in response to John Griggs)Then you do something like sum( sum(100) ). Which makes no sense and is not correct as far as Qlikview is concerned. Which is why you get an error. Use the aggr function if you nest aggregation functions. Or don't and figure it out yourself Perhaps this is what you're after: $(vMarketableWeight)/($(vMarketableWeight) + $(vOutsizeWeight))* 100
Perhaps this helps: It’s all Aggregations

Re: Set analysis with variables
John Griggs Dec 13, 2016 7:48 AM (in response to Gysbert Wassenaar )OK  no worries. Thanks for your help anyway.




Re: Set analysis with variables
Vineeth Pujari Dec 13, 2016 7:17 AM (in response to John Griggs)I think your Expression should be as below,the entire thing
SUM({$<
MarketableOrOutsize = "",
[Size Bucket] = ""
>}
$(vMarketableWeight) )
/
(
SUM({$<
MarketableOrOutsize = "",
[Size Bucket] = ""
>} $(vMarketableWeight) )
+
SUM({$<
MarketableOrOutsize = "",
[Size Bucket] = ""
>} $(vOutsizeWeight) )
)

Re: Set analysis with variables
John Griggs Dec 13, 2016 7:49 AM (in response to Vineeth Pujari)Cheers Vineeth. I tried that one too  but no luck! :(
I know it's the SUM or SUMS that's the problem as my variables already contain summing.....so am guessing that's why this doesn't work either.
Cheers,
John

Re: Set analysis with variables
Vineeth Pujari Dec 13, 2016 10:29 AM (in response to John Griggs)Can you post the exact expression you used? want to make sure we are not missing curly brackets
SUM({$<
MarketableOrOutsize = {'VALUE'},
[Size Bucket] ={''}
>}
$(vMarketableWeight) )
/
(
SUM({$<
MarketableOrOutsize = {'VALUE'},
[Size Bucket] ={''}
>}
>} $(vMarketableWeight) )
+
SUM({$<
MarketableOrOutsize = {'VALUE'},
[Size Bucket] ={''}
>}
>} $(vOutsizeWeight) )
)



Re: Set analysis with variables
John Griggs Dec 13, 2016 11:02 AM (in response to John Griggs)Hi Vineeth,
I misled a bit (sorry) I was trying to empty the two set modifiers (and forgot the syntax!  no swirly brackets or quotes required!!)
It still doesn't work  but this is effectively what I'm trying to do (but with the parts separated as you've suggested):
SUM({$<
MarketableOrOutsize =,
[Size Bucket] =
>}
$(vMarketableWeight) )
/
(
SUM({$<
MarketableOrOutsize =,
[Size Bucket] =
>}
>} $(vMarketableWeight) )
+
SUM({$<
MarketableOrOutsize =,
[Size Bucket]=
>}
>} $(vOutsizeWeight) )
)
Still pretty sure its the whole SUM or SUM thing that's the problem (i.e. each of the three variables are pretty much the same  i.e. SUM[field a] + SUM[field b] + SUM[field c] etc..
It's done like this because we're able to choose these fields in filter visualisations.
Cheers,

Re: Set analysis with variables
Vineeth Pujari Dec 13, 2016 11:06 AM (in response to John Griggs)oh k, instead or Sum() + sum()
try Rangesum(field1,field2...etc)
in the first scenario if any value is null the whole expression becomes null, whereeas rangesum() will adjust for 0's

