QlikView Layout & Visualizations

Discussion Board for collaboration on QlikView Layout & Visualizations.

Not applicable

set analysis for formula like sum(a-b)

Hi,

I'm trying to create an expression with SET.

It is easy to do this...

sum ( {\$<....>} a) - sum ( {\$<....>}  b)

BUT... how do i do it when i want it to be SUM (a - b), applying the same set analyis for both a and b?

Thanks,

Tags (1)
10 Replies
Honored Contributor II

Re: set analysis for formula like sum(a-b)

sum ( {\$<....>} a-b)

or

sum ( {\$<....>} RangeSum(a, -b))

Not applicable

Re: set analysis for formula like sum(a-b)

i can't do that. because the SET criteria for a and b are different....

Honored Contributor II

Re: set analysis for formula like sum(a-b)

I thought you said its the same.

Ok, use Only({\$...} a) - Only({\$...} b)

Not applicable

Re: set analysis for formula like sum(a-b)

yes.. my bad.. typed too quick..

so, perfect, it works...

now, as i'm doing this in pivot table...

the subtotal wont work anymore.. it disappear...

any tips?

Not applicable

Re: set analysis for formula like sum(a-b)

and also.. how does ONLY() works?

i tried to look up in the document, it's not very helpful...

the reason why the total is not working.. because...

instead of doin sum (only(a) - only(b)),

i remove the sum, otherwise the figures wont show...

thats why i asked how does only() works...

it's weird...

Honored Contributor II

Re: set analysis for formula like sum(a-b)

Originally this function checks if your field values are all the same and return this value or null.

But when you know that there is only one value (for your case it was my suggesstion 'cause  you use and without aggregation) you can use it to modify the set (of dimension values) of such fields.

upd:

Oh, I've just realised.

I think when you do sum (only(a) - only(b)),  you forget about sum() sets. You have to wrtite a set expression so that the totals can be calculated.

Not applicable

Re: set analysis for formula like sum(a-b)

Thanks.. after looking at the pivot.. it make sense now.

the only() works when i'm at the lowest value of my pivot, which means i have to expand all the rows.

once i collapse the roll, there's no data to it. that's why there's no value to the total line.

Is there a workaround? so that when it's collapsed, the overall total will work?

Thanks again.

Honored Contributor II

Re: set analysis for formula like sum(a-b)

Actually two workarounds:

1) use aggregation function if possible (like sum and so on)

2) use dimensionality() function to determine the level of expression being calculated.

If(dimensionality()=1,  expression for subtotals, expression for other cells).

Not applicable

Re: set analysis for formula like sum(a-b)

Hi,

I still can't make my expression work.

I have made a similator in attached.

Bascially the percentage by row for zone and month and the selected product is good.

Just that the total percentage is not wanted.

I made a small table below, in the last column, if we can get the expression working, it will be great.

somebody ?

Thanks,