Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

marcoyukon
Contributor

Table, current vs previous month columns.

I have a table and I am trying to get the current vs previous month volume numbers side by side. I am getting "0"' for the Prior month measure. I am not sure what I am doing wrong..

[ProductionDate.Calendar.YearMonth], [Volume] , [Previous Month Volume]

2016-Jan, 121, 0

2016-Feb, 132,0

[Previous Month Volume]:

SUM( { $<

  [ProductionDate.Calendar.Year]    = { $(=Year (addmonths(ProductionDate,-1))) } ,

  [ProductionDate.Calendar.Month]     = { $(=Month(addmonths(ProductionDate,-1))) }

        >} Volume )

Attached is the sample .qvf

Regards

8 Replies
mounachandra1
Contributor

Re: Table, current vs previous month columns.

Hi Marco Barroso,

Please find the attached qvf and let me know if you have any questions.

Thanks

Mouna

marcoyukon
Contributor

Re: Table, current vs previous month columns.

I had looked into "above(sum(Volume))" alternative, however the solution is constrained on the scope of what you can view on the table. For instance, if you filter a row for a month, the prior period will be NULL. Also there is the issue if you sort on the ProductionDate column.

mounachandra1
Contributor

Re: Table, current vs previous month columns.

I got it, Please find the attached qvf file. I think this should work as you expected.

arvind_patil
Valued Contributor II

Re: Table, current vs previous month columns.

HI Marco,

I think it will work for you:

SUM( { $<

  [ProductionDate.Calendar.Year]    = { $(=Year (addmonths(ProductionDate),-1)) } ,

  [ProductionDate.Calendar.Month]     = { $(=Month(addmonths(ProductionDate),-1)) }

        >} Volume )

Thanks,

Arvind Patil

arvind_patil
Valued Contributor II

Re: Table, current vs previous month columns.

HI Marco,

Also try this one:

SUM( { $<  [ProductionDate.Calendar.Month]     = { $(=addmonths(ProductionDate),-1) }

        >} Volume )

Thanks,

Arvind Patil

marcoyukon
Contributor

Re: Table, current vs previous month columns.

Thank you. This did the trick, but why would this expression not work ? It appears the syntax is correct..

SUM( { $<

  [ProductionDate.Calendar.Year]    = { $(=Year (addmonths(ProductionDate,-1))) } ,

  [ProductionDate.Calendar.Month]     = { $(=Month(addmonths(ProductionDate,-1))) }

        >} Volume )

mounachandra1
Contributor

Re: Table, current vs previous month columns.

I think it is better o go with peek funtion in the back end

mounachandra1
Contributor

Re: Table, current vs previous month columns.

I am not sure whats wrong with the above expression. Any ways if it is helpful please close the threat by marking it correct.

Thanks

Mouna Chandra

Community Browser