Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
Coming your way, the Qlik Data Revolution Virtual Summit. October 27-29. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Creator II
Creator II

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
Highlighted
Creator II
Creator II

Try Below one

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

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

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

Highlighted
Creator III
Creator III

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,

Highlighted
MVP & Luminary
MVP & Luminary

Hi Mohan,

Check this link for similar type of expressions.

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

Hope it helps you.

Regards,

jagan.