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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Subtract fields of a dimension

Hello everyone,

Deputy example on the subject.

I have a Dimension Year and Sales.

YEAR SALES

2010     3         

2011     4         

2012     5         

2013     7         

2014     3         

2015     5         


And I want this:


YEAR SALES  OUT

2010     3          3

2011     4          4

2012     5          2

2013     7          7

2014     3          3

2015     5          5

What I want is for one of the years shows sales that year minus the other , and the other showing the sum of sales.

That is, that in the year 2012 instead of 5 I appear 2 on the chart table , the 5 sales least 3 sales 2012 2010.

If I've done :

if ( [Year ] = 2012 , sum ( { < [Year ] = { 2012 } >} Sales) - ( sum ( { < [Year ] = { 2010 } >} Sales) ) , sum ( Sales) )

But this don`t work.

Is this possible ? how? thanks you!

regards

1 Solution

Accepted Solutions
anbu1984
Master III
Master III

Variable : vSum2010=sum ( { < YEAR= { 2010 } >} SALES)

Expr: If(YEAR=2012,Sum({<YEAR={2012}>}SALES)-vSum2010,Sum(SALES))

View solution in original post

4 Replies
swuehl
MVP
MVP

Not sure if I've understood what you are trying to achieve.

Try maybe something like

if ( [Year ] = 2012 ,

     sum (TOTAL { < [Year ] = { 2012 } >} Sales) - ( sum (TOTAL  { < [Year ] = { 2010 } >} Sales) ) ,

      sum ( Sales)

)

anbu1984
Master III
Master III

Variable : vSum2010=sum ( { < YEAR= { 2010 } >} SALES)

Expr: If(YEAR=2012,Sum({<YEAR={2012}>}SALES)-vSum2010,Sum(SALES))

Not applicable
Author

Thank you!!!

Not applicable
Author

I have this problema with your solution:

Total and filters