# Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Highlighted
Contributor III

## Range Product Function

Hi All,

I have data structured as the below.  I was wondering if it is possible to create a RangeProduct type function to calculate YTD,QTD,etc calculations.

 Date Return 1/31/2018 1.011010404 2/28/2018 1.005565826 3/31/2018 1.007899406 4/30/2018 1.0039712 5/31/2018 1.005528985 6/30/2018 1.005855925 7/31/2018 1.007522803 8/31/2018 1.007913107 9/30/2018 1.00652716 10/31/2018 1.002180224 11/30/2018 0.996697694 12/31/2018 0.992635858

So for example when I select 3/31/2018 I want my calculation for YTD to be

Sum({<[Date] = {'3/31/2018'}>}Return) * Sum({<[Date] = {'2/28/2018'}>}Return) * Sum({<[Date] = {'1/31/2018'}>}Return)

Thanks!

Mark

Tags (3)
Labels (1)
• ### Range Product

1 Solution

Accepted Solutions MVP

## Re: Range Product Function

Try this

`=exp(Sum({<Date = {"<=\$(=Date(Max(Date), 'M/D/YYYY'))"}>}Log(Return)))`
10 Replies MVP

## Re: Range Product Function

May be this

`exp(RangeSum(Above(Log(Sum(Return)), 0, RowNo())))`
Contributor III

## Re: Range Product Function

Thanks Sunny, this looks like it would work in a table but I am looking to create a few KPI Objects (one for YTD, QTD,etc.)   Do you know how you could apply this formula there?

Thanks,
Mark

Contributor III

## Re: Range Product Function

Any thought on how this would be possible in a KPI?

Thanks MVP

## Re: Range Product Function

Try this

`=exp(Sum({<Date = {"<=\$(=Date(Max(Date), 'M/D/YYYY'))"}>}Log(Return)))`
Contributor III

## Re: Range Product Function

Does not seem to be working.  I get the correct sum of returns using below formula

Sum({<[CPDate],Date = {">=\$(=QuarterStart(Max(Date)))"}>}Log(PeriodPL))

however when I add the exp() function my KPI returns null

Exp(Sum({<[CPDate],Date = {">=\$(=QuarterStart(Max(Date)))"}>}Log(PeriodPL))) MVP

## Re: Range Product Function

So, this works for you?

`Sum({<[CPDate],Date = {">=\$(=QuarterStart(Max(Date)))"}>}Log(PeriodPL))`
Contributor III

## Re: Range Product Function

Right,

But when I add the exp() function around it I return null in my KPI

Contributor III

## Re: Range Product Function

Hi Sunny,

This works the issue was my values for return were wrong (over 100) so the exp function was becoming too high a number for Qlik to recognize.

Thanks,

Mark MVP

## Re: Range Product Function

Not sure, but seems to work for me based on the sample provided 