# New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
QlikWorld 2023, a live, in-person thrill ride. Save \$400 before Dec 31st: REGISTER NOW!
cancel
Showing results for
Did you mean:
Creator III

## Calculate difference two columns pivoting table only 1 dimension qlik sense

Hi Experts! I need your help to calculate difference or variation of two columns pivoting table only 1 dimension qlik sense.

I need to add another column with the official team variation and backup.

Dimension Row

Company

Column

equipment

Measure

Sum(Sales)

8 Replies
Specialist III

=Sum({<equipment={'officer'}>} sales)-Sum({<equipment={'backrest'}>} sales)

try this as ur variance

Channa
Creator III
Author

It has not worked for me is not calculating correctly the variation, in the green box the variation should be -3 of the backup

Specialist III

before(sum(Value))-sum(Value)

Channa
Creator III
Author

It worked for me changing before for after, but I need the variation to be added as a 3 column.

Creator III
Author

It has stayed like this but I do not want to show it like that.

Specialist III

try to make table instead of pivot or try ad them as columns

Channa
Creator III

Hi guitartrova,

If you need to add a custom column to  pivot table, you can do it by using "valuelist" function to add custom values.

Dimension Row : Company

Column : ValueList('officer','backrest','Var')

Measure :

pick(match(ValueList('officer','backrest','Var'),'officer','backrest','Var'),
sum({<equipment={'officer'}>}value),
sum({<equipment={'backrest'}>}value),
(sum({<equipment={'officer'}>}value)-sum({<equipment={'backrest'}>}value))
)

Output :

Hope it helps,

Partner - Contributor III

Hi, do you know how to set the Var background color in this case?
(if Var<0, red, green)

Tags
Community Browser