Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

businessintelli
New Contributor III

Sum of the same companies in different years

Hello,

I have different companies in different years. I want to calculate the sum of the same companies in the  bar chart. The sum also should be for the max date.Bar should look like this

Capture.PNG

1 Solution

Accepted Solutions
MVP
MVP

Re: Sum of the same companies in different years

It can be done using set analysis

Sum({<Company = p({<Year = {"$(=Max(Year) - 1)"}>})>}Measure)

19 Replies
jaumecf23
Contributor III

Re: Sum of the same companies in different years

Hi,

I understand that you need two dimensions : Company and Year.

and one Expression : sum(Amount)

YoussefBelloum
Esteemed Contributor

Re: Sum of the same companies in different years

Hi,

try to attach some screen shots of the result you have, what is actually wrong, the desired output, the expression and dimension used.

businessintelli
New Contributor III

Re: Sum of the same companies in different years

For example,

In 2016 ---- Companies : A,B,C,D,E,F

  In 2017 ---- Companies: A,B,C,D,E,F,G,H

I want to have the sum of the companies (A,B,C,D,E,F) in 2016 and in 2017.

singhpooja
Contributor III

Re: Sum of the same companies in different years

Hi,

Can you please share some sample data or detailed questions.

Here it seems that you want 2 dimensions one is your companies and other is years and sum(amount) as measures. So for this simply you can take bar chart and implement that.

Thanks,

  Pooja

ChennaiahNallani
Contributor III

Re: Sum of the same companies in different years

take Dimension as a Year and measure sum({<Companies ={'A','B','C','D','E','F'}>}FieldName)

for all Companies sum({<Companies ={"*"}>}FieldName)

singhpooja
Contributor III

Re: Sum of the same companies in different years

Do you want like following... If yes ..simple take take bar chart and stacked companies from presentation.

Let me know it this works for you.

Untitled.png

Thanks,

Pooja

MVP
MVP

Re: Sum of the same companies in different years

It can be done using set analysis

Sum({<Company = p({<Year = {"$(=Max(Year) - 1)"}>})>}Measure)

businessintelli
New Contributor III

Re: Sum of the same companies in different years

Thank you all for your responses, 

In 2016 there were 5 companies , In 2017 two companies were  added. But I want to show the sum of the 5 companies that were in the last year too.  This formula seems correct, but  the sum is calculated for the 7 companies in 2017. ( I hope you understand what I mean)

MVP
MVP

Re: Sum of the same companies in different years

I do and I would expect it to show the sum of only those 5 companies which were present in 2016. Would you be able to share an example where you can demonstrate it not working? This way we can see what is going on