# New to QlikView

Discussion board where members can get started with QlikView.

Highlighted
New Contributor III

## minYear to Maxyear (YTD)

hi,

I'm new to Qlikview and am trying to get something I thought was relatively simple but seems bit difficult.please help me to get this.

i have year field(FY)-2016,2017,2018,2019

Variables : vMinyear and vMaxyear

have to calculate Revenue

suppose if i select 2016 output should be 2016 to 2019

if 2017: 2017 ,2018, 2019

2018: 2018 to 2019

i have tried like below

sum({<FY={">=\$(vMinyear)<=\$(vMaxyear)"}>}Revenue) but it showing selected year only.

same for  Quarter

Please let me know how to achieve this via set analysis.

Chandra

Tags (2)
3 Solutions

Accepted Solutions
Employee

## Re: minYear to Maxyear (YTD)

Try this:
=Sum({\$<FY={\$(=>=\$(vMinYear))}>}Revenue)
Honored Contributor II

## Re: minYear to Maxyear (YTD)

Try below

In Variable overview

vMinyear       =min(FY)

vMaxyear      =max({1}FY)

Note the = i have put before the variable

use your expression as it is and it will work , if it doesn't let me know.

Learning never stops.
Honored Contributor II

## Re: minYear to Maxyear (YTD)

I have attached a sample.

Learning never stops.
24 Replies
Employee

## Re: minYear to Maxyear (YTD)

Try this:
=Sum({\$<FY={\$(=>=\$(vMinYear))}>}Revenue)
New Contributor III

## Re: minYear to Maxyear (YTD)

HI Lisa,

still its not working .

Regards,

Chandra

Employee

## Re: minYear to Maxyear (YTD)

Sorry, just noticed should read =Sum({\$<FY={\$(=>=\$(vMinyear))}>}Revenue)
It worked for me
Honored Contributor II

## Re: minYear to Maxyear (YTD)

how does your vMaxyear and vMinyear look like?

When you select an year it will be automatically be the min and max year. You need the condition when 2017 selected is

>=2017 <=2019 right so to do that you need to change your vMaxyear defination , assuming it is just max(year) you need to change it to max({1}year), so this will not change with selection , if you need current year use year(today()) in the vMaxyear expression. You can leave vMinyear as it is then your expression shall work.

Learning never stops.
New Contributor III

## Re: minYear to Maxyear (YTD)

hi Thakur,

my variable is same as you told

=Max({1}Maxyear)

is anything wrong in expression.pls check

=sum({<FY={">=\$(vMinyear)<=\$(vMaxyear)"}>}Revenue)

Thanks,

Chandra.

Honored Contributor II

## Re: minYear to Maxyear (YTD)

Hi

How does your vMinYear looks like ? Is the field FY number please check that as well. Try and if it doesn't work we can work out a sample .

Thanks

Learning never stops.
Honored Contributor II

## Re: minYear to Maxyear (YTD)

@chandra63 wrote:

my variable is same as you told

=Max({1}Maxyear)

Shouldn't your variable be =max({1}FY) ?

Learning never stops.
New Contributor III

## Re: minYear to Maxyear (YTD)

FY is field

FY

2016

2017

2018

2019

Min(statistic_date) as MinDate,
Max(statistic_date) as MaxDate,
min(FY) as Minyear,
max(FY) as Maxyear
RESIDENT Revenue;

vMinyear=min(FY)

please check this vMinyear variable. is it right?

Thanks & Regards

CHANDRA

Honored Contributor II

## Re: minYear to Maxyear (YTD)

Try below

In Variable overview

vMinyear       =min(FY)

vMaxyear      =max({1}FY)

Note the = i have put before the variable

use your expression as it is and it will work , if it doesn't let me know.

Learning never stops.