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

Announcements
Q&A with Qlik - Qlik Cloud Migration: Questions about migrating to Qlik Cloud? Catch the latest replay!
cancel
Showing results for 
Search instead for 
Did you mean: 
n1ef5ng1
Creator
Creator

Last year current month

 

I have a problem displaying out the last month. When a user select April 2013, I will have two expression that show April 2013 and April 2012. It will take the current month.

This is my expression for both of them

Label : Only(Month) and Only(Year)-1

Sum(

  {$<Line_Code={'ADV','MAL','AMT'},Derived_Status={'IMPT','EXPT'},Derived_Container_Class_Name={'LADEN'},Month_Id={"<= $(=Max(Month_Id))"},Year ={$(=Max(Year)-1)},Month=, Month_Year = >}TEU

 

=

ONLY(Month) & ' ' & ONLY(Year

)

sum({<Line_Code={'ADV','MAL','AMT'},Derived_Status={'IMPT','EXPT'},Derived_Container_Class_Name={'LADEN'},Month_Id={$(=Max(Month_Id))},Year = ,Month=, Month_Year = >}  TEU)

For Only(Month) and Only(Year), current year. i managed to get the value correctly,

for Only(Month) and Only(Year)-1, I get a YTD of Jan - Apr 2012 instead. I am actuallly looking for Apr 12 current month instead.

why is this so, thanks

Labels (1)
16 Replies
n1ef5ng1
Creator
Creator
Author

ok i will try,

but anywhere this is my code,

Sum(
  {$<Line_Code={'ADV','MAL','AMT'},Derived_Status={'IMPT','EXPT'},Derived_Container_Class_Name={'LADEN'},Month_Id={" $(=Max(Month_Id))"},Year ={$(=Max(Year)-1)},Month=, Month_Year = >}TEU

  /
Aggr(
  NODISTINCT
   Sum(
    {<Line_Code={'ADV','MAL','AMT'},Derived_Status={'IMPT','EXPT'},Derived_Container_Class_Name={'LADEN'},Month_Id={"$(=Mac(Month_Id))"},Year ={$(=Max(Year)-1)}, Month=, Month_Year = >} 
   TEU),Year
  )
      )

n1ef5ng1
Creator
Creator
Author

ok i will try,

but anywhere this is my code,

Sum(
  {$<Line_Code={'ADV','MAL','AMT'},Derived_Status={'IMPT','EXPT'},Derived_Container_Class_Name={'LADEN'},Month_Id={" $(=Max(Month_Id))"},Year ={$(=Max(Year)-1)},Month=, Month_Year = >}TEU

  /
Aggr(
  NODISTINCT
   Sum(
    {<Line_Code={'ADV','MAL','AMT'},Derived_Status={'IMPT','EXPT'},Derived_Container_Class_Name={'LADEN'},Month_Id={"$(=Mac(Month_Id))"},Year ={$(=Max(Year)-1)}, Month=, Month_Year = >} 
   TEU),Year
  )
      )

Sokkorn
Master
Master

Hi,

Look on you expression, found something wrong

n1ef5ng1 wrote:

ok i will try,

but anywhere this is my code,

Sum(
  {$<Line_Code={'ADV','MAL','AMT'},Derived_Status={'IMPT','EXPT'},Derived_Container_Class_Name={'LADEN'},Month_Id={" $(=Max(Month_Id))"},Year ={$(=Max(Year)-1)},Month=, Month_Year = >}TEU ) // Missing bracket

  /
Aggr(
  NODISTINCT
   Sum(
    {<Line_Code={'ADV','MAL','AMT'},Derived_Status={'IMPT','EXPT'},Derived_Container_Class_Name={'LADEN'},Month_Id={"$(=Mac(Month_Id))"},Year ={$(=Max(Year)-1)}, Month=, Month_Year = >} 
   TEU),Year
  )
      ) // Should take it out

Now let try:

Sum({$<Line_Code={'ADV','MAL','AMT'},Derived_Status={'IMPT','EXPT'},Derived_Container_Class_Name={'LADEN'},Month_Id={$(=Max(Month_Id))},Year ={$(=Max(Year)-1)},Month=, Month_Year = >} TEU)

/

Aggr(

  NODISTINCT

    Sum(

    {<Line_Code={'ADV','MAL','AMT'},Derived_Status={'IMPT','EXPT'},Derived_Container_Class_Name=    {'LADEN'},Month_Id={$(=Max(Month_Id))},Year ={$(=Max(Year)-1)}, Month=, Month_Year = >} TEU)

,Year)

Regards,

Sokkorn

n1ef5ng1
Creator
Creator
Author

the whole expression is invalid when i paste the code that you gave.

laujerry
Creator
Creator

have u tried decomposing your expressions into short one first

like showing the Sum part and Aggr part in separate expressions, removing part of the set conditions?

can u still get the expected result?

n1ef5ng1
Creator
Creator
Author

i tried, sum was correct. Aggr actually display YTD for 2013 and not last year, 2012

nizamsha
Specialist II
Specialist II

if u want lastyear current month and current date

u can write like in ur expression

year(today())-1,month(today()),day(today())

this will give lastyear,currentmonth, currentdate

eg::

22:7:2017 instead of this it will give

2:7:2012