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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
JMIltner97
Contributor
Contributor

Matrix calculations

I am trying the following:

I have a Table containing transactional data and I want to create a Matrix, which shows the Dates as the Rows and the sum of sales for each country in the columns. So far so good, as thats not too complicated.

Now I however would want to show a last column containing the sum of sales (for all countries combined) for the exact date but 1 year prior.

I tried writing formulas with set analysis but struggle as they are not evaluated at a row context.

How can I achieve this? I am super happy for any tips and tricks on hwo to achieve this?

 

Best,

Jan

Labels (4)
1 Reply
Padma123
Creator
Creator

Try it once..

in script

table1:

load *,AddYears(date,-1) as previousyear;

table2:

load country,Sum(sales) as [each country sales]
Resident table1
Group by country;

in pivot table

row dimension-date

column dimension-country

measure-sum([each country sales])

measure2-Sum(total{<country=p({<previous>})>}sales)