Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
On Demand Webinar: See Why Thousands of QlikView Users Have Switched to Qlik Sense. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
ttollin11
Contributor III
Contributor III

Setting multiple field values in a variable

I am trying to write a previousQuarter variable that is comprised of the following:

= if

     (

          GetFieldSelections([Quarter]) = 'Q1',

          [Deposit Year] = (GetFieldSelections([Deposit Year]) - 1) and (Quarter = 'Q4'),

          [Quarter] = 'Q' & (Right(Quarter, 1) - 1)

     )

I need this variable to use in pulling the previous quarter balance, and the if() here needs to be able to handle when Q1 is selected and so there needs to be a comparison to the previous year's Q4 balance.

I think that maybe "[...] = x" is not appropriate syntax; so is there a proper way to write this, or am I going about this the wrong way?

Thanks!

Edit: Added sample .qvw.

Message was edited by: Tyler Tollin

11 Replies
ttollin11
Contributor III
Contributor III

Thanks Sunny. Is it normal for this not to work at the record level?

When I use

=sum({<[Record Date] = P([Previous Quarter End]), [Deposit Month], [Deposit Quarter], [Deposit Year]>} [Current Balance Amount])

for column Previous Qtr Bal, the below results. That's the right value for that date, but it should be in a single record. I've tried using variables, but that returns 0.

%DepositFact_PK =[Record Date] =RecordYYYYMM =[Current Balance Amount] =[Previous Quarter End] Previous Qtr Bal
3/1/2018 201803 157.7900 12/1/2017 303.7000
201712|50546303.7000
201803|505463/1/2018201803157.790012/1/20170.0000
sunny_talwar

Since date is part of the dimension, you will need to use Inter-Record Functions here... may be with Above()

=Above(Sum({<[Record Date] = P([Previous Quarter End]), [Deposit Month], [Deposit Quarter], [Deposit Year]>} [Current Balance Amount]))