Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Current value vs Last month & Last Year

Hi,

I'm only using QV since yesterday so most probably this is a newbie question.

In my db I have a month and year field, with some stockvalues. I made a period field :

Date(MakeDate(Year,Month),'MM-YYYY') AS Period, which works fine

Ok, I use this period field now to build a "stock level per month" graph. This gives the following result (= I see what I want to see) :

Capture.JPG

But now I want to have 2 dashboard charts which gives me the % increase/decrease of

1. current month stocklevel vs last month, and

2. the current month stocklevel vs last year.

so basically i want : sum(this period) / sum(last period) and sum(this period) / sum(same period last year).

how can i do this?

Thanks for the input guys

1 Solution

Accepted Solutions
Not applicable
Author

Hi Jagan, I found by myself what the solution is.

I defined 3 months:

Curr_Mth='10.2011'

Last_Mth='9.2011'

Last_Yr='10.2010'

then, in the current vs last month % diff chart i used the expression,

=(sum(if(Period=$(Curr_Mth),varPrdVal)))/sum(if(Period=

$(Last_Mth),varPrdVal))-1

for the vs last year chart i did the same

=(sum(if(Period=

$(Curr_Mth),varPrdVal)))/sum(if(Period=$(Last_Yr),varPrdVal))-1

it works, I'm happy for my first QV day

View solution in original post

3 Replies
Not applicable
Author

well, i guess, most probably I'll have to keep a variable "Curr_Mth","Last_Mth" and "Last_Yr" and assign the right period to it, then I can do in my chart Curr_Mth / Last_Mth and so on

but I don't know how to do this in QV.

Thanks

jagan
Luminary Alumni
Luminary Alumni

Hi,

Can you uplaod the sample file with data.

Regards,

Jagan.

Not applicable
Author

Hi Jagan, I found by myself what the solution is.

I defined 3 months:

Curr_Mth='10.2011'

Last_Mth='9.2011'

Last_Yr='10.2010'

then, in the current vs last month % diff chart i used the expression,

=(sum(if(Period=$(Curr_Mth),varPrdVal)))/sum(if(Period=

$(Last_Mth),varPrdVal))-1

for the vs last year chart i did the same

=(sum(if(Period=

$(Curr_Mth),varPrdVal)))/sum(if(Period=$(Last_Yr),varPrdVal))-1

it works, I'm happy for my first QV day