Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

calculating margin

Hello, I'm trying to calculate the relative margin for products which have a VAT H(igh) or L(ow) but it does nog give any result back, i think because i'm trying to take the sum of it all Qlikview does not understand what i want. This is the formula i am using

=((sum(
if(btwcode = {'H'},

{<date = {'$(=Date(today()-1))'} >} sales)/1.19)-(sum({<date = {'$(=Date(today()-1))'} >} inkoopprijs)))/(sum({<date = {'$(=Date(today()-1))'} >} sales)/1.19)
,
=((sum({<date = {'$(=Date(today()-1))'} >} sales)/1.06)-(sum({<date = {'$(=Date(today()-1))'} >} inkoopprijs)))/(sum({<date = {'$(=Date(today()-1))'} >} sales)/1.06)
)

Is the formula wrong or my approach?

1 Solution

Accepted Solutions
swuehl
MVP
MVP

I believe you are using an equal sign where it mustn't be placed (first letter, 6th line).

Then and more important, you are embedding aggregation functions into another aggregation function (sum into sum), which is not allowed without using advanced aggregation.

I think your then-else branches are also not as you intended.

To help you more with your syntax, could you describe a bit closer in what context you want to use your expression (e.g. in a table chart (with what dimensions?))? For example, is your data already grouped by btwcode?

View solution in original post

1 Reply
swuehl
MVP
MVP

I believe you are using an equal sign where it mustn't be placed (first letter, 6th line).

Then and more important, you are embedding aggregation functions into another aggregation function (sum into sum), which is not allowed without using advanced aggregation.

I think your then-else branches are also not as you intended.

To help you more with your syntax, could you describe a bit closer in what context you want to use your expression (e.g. in a table chart (with what dimensions?))? For example, is your data already grouped by btwcode?