# New to QlikView

Discussion board where members can get started with QlikView.

Announcements

Not applicable

## Last year figures

Hi,

I use an expression to get current year cumulative figures which perfectly works :

sum ({\$<Year = {\$(=max(Year))}, Month = {"<=\$(=max({<Year={\$(=max(Year))}>} Month))"}>} Sales)

I'd like to display last year same figures. The idea is when i select a month (april 2011 for exemple), I'd like to see sales from january to april 2011 (expression above) and sales from january to april 2010 and I can't figure out how to get this.

Many thanks for yor help.

Franck

1 Solution

Accepted Solutions
Not applicable

## Last year figures

Hi,

Try the expression

sum ({\$<Year = {\$(=max(Year)-1)}, Month = {"<=\$(=max(Month))"}>} Sales)

This works if your month is in Numerice format.

Regards,

Jagan.

12 Replies
Not applicable

## Last year figures

Hi

You can use following

sum ({\$<Year = {\$(=max(Year)-1)}, Month = {"<=\$(=max({<Year={\$(=max(Year))}>} Month))"}>} Sales)

This will give you details of previous year.

Is it ok?

Not applicable

## Last year figures

This expression gives me the whole last year figures and what I'd like to get is the sales for the period depending on the month selection. For exemple, if i select april 2011, i' want to obtein the figures from january to april 2011.

Regards.

Franck

Not applicable

## Last year figures

Hi,

Try the expression

sum ({\$<Year = {\$(=max(Year)-1)}, Month = {"<=\$(=max(Month))"}>} Sales)

This works if your month is in Numerice format.

Regards,

Jagan.

Not applicable

## Last year figures

Unfortunately, the format of the month is MMM-YYY and your expression still gives me the whole last year sum of sales.

Regards,

Franck

Not applicable

## Last year figures

Hi,

If you have a date field then check with this

=sum ({\$<Year = {\$(=max(Year)-1)},DataField={">=MonthStart(Max(DateField),-12)"}, Month=}>} Sales)

Hope it helps

Celambarasan

Not applicable

## Last year figures

Hi,

Arrive the month in Numeric format, it would be easier for you to calculate this type fo calculations.

*

Month(Date(Date#(MonthFieldName, 'MMM-YYYY'), 'MM/DD/YYYY')) AS Month

FROM DataSource;

Now use the above expression.

Hope this helps you.

Regards,

Jagan.

Not applicable

## Last year figures

Hi,

You can probably use the Month field instead of Month-Year to get the result. If you do not already have a month field (Jan,Feb....), you can create the month field by using month(YourDateFieldName) as Month in the script. Then use the expression that Jagan posted.

As far as  month names are concerned, you could use an inline mapping table for mapping months with their corresponding names as follows....

Months_Map:

Month, M_Name

1, Jan

2, Feb

3, Mar

4, Apr

5, May

6, Jun

7, Jul

8, Aug

9, Sep

10, Oct

11, Nov

12, Dec

];

Hope this helps.

Regards,

-Khaled.

Not applicable

## Last year figures

Thanks for your answers, but it still doesn't work. The big problem is that I can't do nothing with the script because I work with VPN connection and I can't access to the database.

Thanks anyway

Not applicable

## Re: Last year figures

By using partial reload, I could insert a numeric month field. Here is the code :

[Calendar]: