# Qlik Sense App Development

Valued Contributor II

## How to get Last year same period Stock Amount ?

Hi All

May i know how to change the below SET expression , to get Last year same period Stock Amount ?

Money(RangeSum(
Above(RangeSum(Above(Sum({<year, month, GL_CODE = {50010}>}[Amount]*1), 0, RowNo()))),
-Sum({<GL_CODE = {50010}>}TOTAL Aggr(Sum({<year, month, GL_CODE = {50010}>}[Amount]*1), YearMonth)))
, \$(vMoneyFormatK_GL))

So that my Table 2 have  one more column display LY same period stock amount.

Paul

1 Solution

Accepted Solutions
MVP

## Re: How to get Last year same period Stock Amount ?

Try this:

Money(RangeSum(Sum({<year, month, GL_CODE = {50010}>}[Amount]*-1),

Sum({<year, month, GL_CODE = {50010}, YearMonth = {"=YearMonth > AddYears(Max(TOTAL YearMonth), -1) and YearMonth <= Max(TOTAL YearMonth)"}>}[Amount]*1))

, \$(vMoneyFormatK_GL))

8 Replies
Valued Contributor II

My QVF

MVP

## Re: How to get Last year same period Stock Amount ?

What is the number that you are expecting to see?

Valued Contributor II

MVP

## Re: How to get Last year same period Stock Amount ?

Slightly more complicated then I imagined, I will work on this at a later time

MVP

## Re: How to get Last year same period Stock Amount ?

Try this:

Money(RangeSum(Sum({<year, month, GL_CODE = {50010}>}[Amount]*-1),

Sum({<year, month, GL_CODE = {50010}, YearMonth = {"=YearMonth > AddYears(Max(TOTAL YearMonth), -1) and YearMonth <= Max(TOTAL YearMonth)"}>}[Amount]*1))

, \$(vMoneyFormatK_GL))

Valued Contributor II

## Re: How to get Last year same period Stock Amount ?

Hi Sunny

Can you also give me last month Amount ? it should be 1.413 million.

Paul

MVP

## Re: How to get Last year same period Stock Amount ?

Try this:

Money(RangeSum(Sum({<year, month, GL_CODE = {50010}>}[Amount]*-1),

Sum({<year, month, GL_CODE = {50010}, YearMonth = {"=YearMonth > AddMonths(Max(TOTAL YearMonth), -1) and YearMonth <= Max(TOTAL YearMonth)"}>}[Amount]*1))

, \$(vMoneyFormatK_GL))

Valued Contributor II

## Re: How to get Last year same period Stock Amount ?

I move this to the top , as i am working on this