# QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Rules, plus terms and conditions, can be found here.
Valued Contributor II

## When current year and month is not selected , how to compute LY YTD sales ?

Hi All

Table 1 is my SET expression need to select the current month and year.

sum({\$<year = {\$(=max(year)-1)}, month = {"<=\$(=max({<year={\$(=max(year))}>} month))"}>}sales/1000)

Now i can only achieve using , Flag , may i know how to make use of SET ?

Sum(if(LY_YTD,sales))

May i know how to modify the above expression so that i don't need to select current year and month ?

Paul

1 Solution

Accepted Solutions
MVP

## Re: When current year and month is not selected , how to compute LY YTD sales ?

Try this may be:

Sum({\$<year = {\$(=Max(year)-1)}, month = {"<=\$(=Max({<year={\$(=Max(year))}, sales = {'*'}>} month))"}>}sales/1)

5 Replies
MVP

## Re: When current year and month is not selected , how to compute LY YTD sales ?

Try this may be:

Sum({\$<year = {\$(=Max(year)-1)}, month = {"<=\$(=Max({<year={\$(=Max(year))}, sales = {'*'}>} month))"}>}sales/1)

Valued Contributor II

## Re: When current year and month is not selected , how to compute LY YTD sales ?

Hi Sunny

Thank you for help on on sales expression , Now i need help on when current year and month is not selected , how to compute LY YTD rEVENUE ?

Table 1 is my SET expression need to select the current month and year.

=SUM({<year = {"\$(=Max(year)-1)"},month={"<=\$(=month)"},rEVENUE={rEVENUE}>}Amount*1)/\$(Columndim89)/1000

May i know how to modify the above expression so that i don't need to select current year and month ? , and Table can display 110 , now display 0

i know i need insert rEVENUE = {'*'} into above expression. But not sure where to plug in. As this expression is total different my previous sales expression.

Paul

MVP

## Re: When current year and month is not selected , how to compute LY YTD sales ?

Check the attached

Valued Contributor II

## Re: When current year and month is not selected , how to compute LY YTD sales ?

Hi Sunny

Thank you so much. May I ask it is okay for me to use the same thread for similar issue ? Or you prefer me open new thread ?

Paul

Sent from my iPhone

MVP

## Re: When current year and month is not selected , how to compute LY YTD sales ?

I think its better to open new threads for a new issue because it will help you get more exposure from other people who are willing to help, but may not check a closed thread.