Skip to main content

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
NEW webinar Dec. 7th: 2023 Outlook, A Pivotal Year for Data Integration SIGN ME UP!
cancel
Showing results for 
Search instead for 
Did you mean: 
mohan2391
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!!

4 Replies
lakkydev
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)

pathiqvd
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,

jagan
Luminary Alumni
Luminary Alumni

Hi Mohan,

Check this link for similar type of expressions.

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

Hope it helps you.

Regards,

jagan.

dia2021
Creator
Creator

Hi Mohan, 

I came through your post. This is exactly what I need. Could you please share how to achieve it? The below-shared answers are not working for me. Did you find the right way to do this calculation? I really appreciate any help you can provide?