# New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Contributor

## Current quarter - previous quarter

Hi,

I have 2 date fields & sales field in excel like below

Quarter    Month        sales

2017Q3    201709       10

2017Q3    201708       20

2017Q3    201707       30

2017Q2    201706       40

2017Q2    201705       50

2017Q2    201704       60

2017Q1    201703       70

2017Q2    201702       80

2017Q2    201701       90

i want to get current quarter sales - (minus) previous quarter based on the quarter selection in front end

if i select 2017Q2 in front end -- it shud show ((40+50+60 = 150) - (70+80+90 = 240)) '-90'

I want "Set Expression" for this..

how to write with functions/variables ? (not hardcoded)

ThankYou!!

3 Replies
Contributor II

## Re: Current quarter - previous quarter

Try Below one

vCurrent_Quarter =     Quarter={"\$(=GetFieldSelections(Quarter))"}

vPrevious_Quarter =    Quarter={"\$(=GetFieldSelections(Quarter)-1)"}

sum({<\$(=vCurrent_Quarterr)>}Sales)- sum({<\$(=vPrevious_Quarter)>}Sales)

Contributor III

## Re: Current quarter - previous quarter

Hi,

Try This,

Sum({<Quarter={"\$(=left(max(PurgeChar(Quarter,'Q')),4)&'Q'&Right(max(PurgeChar(Quarter,'Q')),1))"}>}sales)

-

Sum({<Quarter={"\$(=left(max(PurgeChar(Quarter,'Q'))-1,4)&'Q'&Right(max(PurgeChar(Quarter,'Q'))-1,1))"}>}sales)

Regards,

MVP

## Re: Current quarter - previous quarter

Hi Mohan,

Check this link for similar type of expressions.

https://community.qlik.com/docs/DOC-9144

Hope it helps you.

Regards,

jagan.