

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
;


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your reply sunny
But output is not coming.
Am I doing any mistake in peek function.
Regards
Tripati

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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;


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Sunny,
Superb
Its working fine,
If I want to calculate previous month - current month where i have to change.
Regards
Tripati

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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;


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
