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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
inigoelv
Creator
Creator

LAST YEAR AND CURRENT YEAR

Hello,

I have a problem with the following table:

YearMonthYearCustomerTons
2012012012A100
2012022012B200
2011012011A300
2011022011B400

I would like to create other table like the comparation between actual year and last year:

YearCustomer20122011
2012A100300
2012B200400

I use the expression:

   

But in the column of Year appears 2012 and 2011, in diferent cells. i need the comparasion in the same line.

1 Solution

Accepted Solutions
Not applicable

Hi.

You can create a graph object (table) and put the year as dimension and create expression like

Actual Year

sum({<Year={$(=max(Year))}>} Tons)

Last Year

sum({<Year={$(=max(Year -1))}>} Tons)

I hope this can help you.

Alessandro Furtado

View solution in original post

7 Replies
Not applicable

Hi.

I created an example. I hope this can help you.

Alessandro Furtado

inigoelv
Creator
Creator
Author

Sorry Alessandro:

I have the standar version and don´t let me to open it.

Could you put the expression used?

In addition to the example, the field Year is really Year (MonthYear). I forgot to say it.

Best regards,

Not applicable

Hi.

You can create a graph object (table) and put the year as dimension and create expression like

Actual Year

sum({<Year={$(=max(Year))}>} Tons)

Last Year

sum({<Year={$(=max(Year -1))}>} Tons)

I hope this can help you.

Alessandro Furtado

Anonymous
Not applicable

Dear inigoelv,

      Please fiend the attachment of application and let you know.

Regards

Not applicable

hi

this is exactly according to your requirment.

in script--

LOAD * INLINE [

    year, customer, tons

    2012, A, 100

    2012, B, 200

    2011, A, 300

    2011, B, 400

];

then add pivot chart--

          dimension---   customer

          expression---   (1)      sum({<year={$(=max(year))}>} tons)

                                (2)      sum({<year={$(=max(year -1))}>}tons)

then output like this--

customer20122011
A100300
B200400
inigoelv
Creator
Creator
Author

Hello:

Thanks but the problem is the field year is an expression:

Year=Year (MonthYear)

The reason is becuase I connect all the tables only with MonthYear.

If I use

sum ( {$<Year(MonthYear)= {$(#=Max(Year(MonthYear))-1)

it doesn´t work.

I prefer no create Year as key, becuase it complicate the script.

Best regards,

inigoelv
Creator
Creator
Author

Hi Alessandro:

The answer is correct but I had to eliminate the Year (MonthYear) of the dimension of the chart, because if not appears in diferents lines:

2011A0300 
2011B0400 
2012A1000 
2012B2000

No choice.

Thanks anyway