# New to QlikView

Discussion board where members can get started with QlikView.

Contributor

## QTD,YTD,MTD on selection?

Hi Everyone,

Wanted to know if this is the proper way to calculate data on selection of filter YTD,QTD,MTD. Or is there any other way how i can do it?Thanks for your suggestions.

if(Filter='YTD' or GetSelectedCount(Filter)=0,

only({<POSITION_DATE= {">=\$(=vytdstart)<=\$(=vytdend)"}>} maturity)

,

if(

Filter='MTD',

only({<POSITION_DATE= {">=\$(=vmtdstart)<=\$(=vmtdend)"}>} maturity),

IF(Filter='QTD',

only({<POSITION_DATE= {">=\$(=vqtdstart)<=\$(=vqtdend)"}>} maturity)

)

)

)

Thanks,

Shreya

7 Replies
Honored Contributor II

## Re: QTD,YTD,MTD on selection?

Use Sum instead of ONLY, Your expression logic is correct:

if(Filter='YTD' or GetSelectedCount(Filter)=0,

Sum({<POSITION_DATE= {">=\$(=vytdstart)<=\$(=vytdend)"}>} maturity)

,

if(

Filter='MTD',

Sum({<POSITION_DATE= {">=\$(=vmtdstart)<=\$(=vmtdend)"}>} maturity),

IF(Filter='QTD',

Sum({<POSITION_DATE= {">=\$(=vqtdstart)<=\$(=vqtdend)"}>} maturity)

)

)

)

Contributor

## Re: QTD,YTD,MTD on selection?

Hi arjun,

the maturity field has dates so we want to use only of the maturity/segment.

Also i am facing out of memory issue.Is there any other way to handle it.Thanks

Contributor

## Re: QTD,YTD,MTD on selection?

Highlighted
New Contributor III

## Re: QTD,YTD,MTD on selection?

That date field convert into num

eg: num(POSITION_DATE)

then you apply

New Contributor III

## Re: QTD,YTD,MTD on selection?

That date field convert into num

eg: num(POSITION_DATE)

then you apply MVP

## Re: QTD,YTD,MTD on selection?

Try to share an app with sample data replicating your ask. That way, we would be able to help you better and faster.

Honored Contributor II

## Re: QTD,YTD,MTD on selection?

It is much to share the sample data to provide exact solution.shreya.nadkarni