Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

Not applicable

Expression

Hi There,

I want to create an expression to look at the the sameday on Current month and previous month, for instance

CM = 20160801 to 20160830

PM = 20160701 to 20160730

Many thanks,

Treasure

10 Replies
oknotsen
Honored Contributor III

Re: Expression

Maybe the inmonth() function is what you are looking for.

inmonth ‒ QlikView

May you live in interesting times!
Partner
Partner

Re: Expression

try addmonths(CM,-1)

how your Expression would look like to Combine sameday value of CM and PM?

Not applicable

Re: Expression

Hi Rudolf,

I have two Charts (one showing CM and the other showing PM)

so on the current month chart(there's data from the first of this month until today),

and on the previous month chart(there's data from the first of the previous month until month end (20160731)

so I want to compare 30th of this month and the 30th of the pm

thanks,

Partner
Partner

Re: Expression

you may use the Expression with addmonths in your Chart with PM

do you show each day of month in the Chart?

can you post sample qvw?

balrajahlawat
Esteemed Contributor

Re: Expression

may be like this?

Create two variables

1. vCurrentMonth

=Max(Month)

and make ur expression like:

sum( {$<Year = {$(#vCurrentMonth)}>} Sales )

2. vLastMonth

=Max(Month-1)

sum( {$<Year = {$(#vLastMonth)}>} Sales )

or

For Current Month Sales:

=sum({<CalendarYear={$(=max(CalendarYear))},CalendarMonthName={$(=Month(Max(InvDate)))}>}INVC_ITEM_AMT)

For Last Month Sales:

=sum({<CalendarYear={$(=max(CalendarYear))},CalendarMonthName={$(=month(addmonths((max(InvDate)),-1)))}>}INVC_ITEM_AMT)

balrajahlawat
Esteemed Contributor

Re: Expression

Not applicable

Re: Expression

VS.PNG

Partner
Partner

Re: Expression

you wrote that you want to compare the sameday from current month and previous month

but you want to compare the current month vs previous month? or do you select the day by a selection box?

anyway: if you define the Expression for PM like

sum({<yourdatefield={'$(=addmonths(max/(yourdatefield),-1)'}>}value)

you select month: you get months value

you select day and month: you get value of this month/day

Not applicable

Re: Expression

Hi Rudie, It worked(sum({<yourdatefield={'$(=addmonths(max/(yourdatefield),-1)'}>}value)),

THANK you so much