Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
tripatirao
Creator II

use of peek function in if condition

Dear All,

I want to calculate current month and previous month difference of a data.

I got the output when i take a single dimension but when I am taking multiple dimension  it is not coming.


I have attached both the qlikview file Please check and do the needful.



In the attached qlikview-groupby.qvw I am getting output for the single dimension

but in attached ytdapplication.qvw i am not getting the output as I have attached another field GL description in it.

Kindly let me know any further details you want form my side.

Regards

Tripati

1 Solution

Accepted Solutions
sunny_talwar

Do you need this in your if statement?

Peek(Date)=Date?

May be this:

Data3:

Load RowNo(),

  FiscalYear,

    MonthName,

    Date,

    //PK,

    CalenderYear,

    CalenderMonth,

    fMonth,

    FinancialYear,

    FinancialMonth,

    [GL Description],

    Data,

  If(RowNo() = 1, RangeSum(Data, 0),

  If(Peek([GL Description])=[GL Description],-1*(RangeSum(Peek(Data),0)-numsum(Data)),RangeSum(Data,0))) as CurrentMonthValue

Resident Data2

Order By [GL Description] asc,

Date asc;

View solution in original post

8 Replies
sunny_talwar

I think you need to order by GL Description also

Data3:

Load RowNo(),

  FiscalYear,

    MonthName,

    Date,

    //PK,

    CalenderYear,

    CalenderMonth,

    fMonth,

    FinancialYear,

    FinancialMonth,

    [GL Description],

    Data,

  If(RowNo() = 1, RangeSum(Data, 0),

  If(Peek(Date)=Date and Peek([GL Description])=[GL Description],-1*(RangeSum(Peek(Data),0)-numsum(Data)),RangeSum(Data,0))) as CurrentMonthValue

Resident Data2

Order By [GL Description], Date asc;

tunoi
Creator

Add [GL Description] in order by clause like below

Data3:

Load RowNo(),

  FiscalYear,

    MonthName,

    Date,

    //PK,

    CalenderYear,

    CalenderMonth,

    fMonth,

    FinancialYear,

    FinancialMonth,

    [GL Description],

    Data,

  If(RowNo() = 1, RangeSum(Data, 0),

  If(Peek(Date)=Date and Peek([GL Description])=[GL Description],-1*(RangeSum(Peek(Data),0)-numsum(Data)),RangeSum(Data,0))) as CurrentMonthValue

Resident Data2

Order By

    Date asc,

    [GL Description]  asc

;

tripatirao
Creator II
Author

Thanks for your reply sunny

But output is not coming.

Am I doing any mistake  in peek function.

Regards

Tripati

sunny_talwar

Do you need this in your if statement?

Peek(Date)=Date?

May be this:

Data3:

Load RowNo(),

  FiscalYear,

    MonthName,

    Date,

    //PK,

    CalenderYear,

    CalenderMonth,

    fMonth,

    FinancialYear,

    FinancialMonth,

    [GL Description],

    Data,

  If(RowNo() = 1, RangeSum(Data, 0),

  If(Peek([GL Description])=[GL Description],-1*(RangeSum(Peek(Data),0)-numsum(Data)),RangeSum(Data,0))) as CurrentMonthValue

Resident Data2

Order By [GL Description] asc,

Date asc;

tripatirao
Creator II
Author

Thanks Sunny,

Superb

Its working fine,

If I want to calculate previous month - current month where i have to change.

Regards

Tripati

sunny_talwar

In the script? May be this:

May be this:

Data3:

LOAD *,

          Data - CurrentMonthValue as NewColumn;

Load RowNo(),

  FiscalYear,

    MonthName,

    Date,

    //PK,

    CalenderYear,

    CalenderMonth,

    fMonth,

    FinancialYear,

    FinancialMonth,

    [GL Description],

    Data,

  If(RowNo() = 1, RangeSum(Data, 0),

  If(Peek([GL Description])=[GL Description],-1*(RangeSum(Peek(Data),0)-numsum(Data)),RangeSum(Data,0))) as CurrentMonthValue

Resident Data2

Order By [GL Description] asc,

Date asc;

tripatirao
Creator II
Author

Hi,

where i have to change in the following code  to  get the previousmonth - current month data

If(RowNo() = 1, RangeSum(Data, 0),

  If(Peek([GL Description])=[GL Description],-1*(RangeSum(Peek(Data),0)-numsum(Data)),RangeSum(Data,0))) as CurrentMonthValue



Regards

Tripati

sunny_talwar

May be this:

If(RowNo() = 1, RangeSum(Data, 0),

  If(Peek([GL Description])=[GL Description],-1*(RangeSum(Peek(Data),0)-numsum(Data)),RangeSum(Data,0))) - Data as Change