Skip to main content
Announcements
See why Qlik is a Leader in the 2024 Gartner® Magic Quadrant™ for Analytics & BI Platforms. Download Now
cancel
Showing results for 
Search instead for 
Did you mean: 
abhaysingh
Specialist II
Specialist II

Previous month Sales

I want to show previous month sales.

i my calender i have two month,   FMonth and Month

In my whole application i am following FMonth and it is working well.

Previous month i am calcilating as

variable= Max(FMonth-1)

calculating expression is

=sum({<FMonth = {$(variable)}>}sales

but it is giving me error,as value 0.

pls help me .........


5 Replies
er_mohit
Master II
Master II

Try this

=sum({<FMonth = {'=$(=variable)'}>}sales

or

sum({<FMonth = {"=$(=variable)"}>}sales

VishalWaghole
Specialist II
Specialist II

sum({<FMonth = {'=$(variable)'}>}sales)

use single quote.

and close opening bracket at end.

It will work.

-- Regards,

Vishal Waghole

abhaysingh
Specialist II
Specialist II
Author

when i am doin MAX(FMonth) it is giving me Aug

but when i am Doing max(FMonth-1) it is giving me 4 if max month aug is selected,

i thing instead of 4 it should give me july

VishalWaghole
Specialist II
Specialist II

Caluculate your previous month as like

=AddMonths(Max(FMonth),-1)

Hope this will give you result as Jul

-- Regards,

Vishal Waghole

tresesco
MVP
MVP

This depends on how you create the field in the script. Generally, it is easier to calculate the previous month from date field. Try to redefine your variable like:

variable= Month(AddMonths(Max(Datefield), -1))

And then your expression =sum({<FMonth = {'$(variable)'}>}sales)  should work.