Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Setup Current and Previous period Amount at same row

Hi QlikView eprts,

I have source table with columns, Date, Account, Amount. Want to transform that to following format of Date, Account, Amount, PY AMT (for further calculations).

Tried to read source table in two different table and then those two resident table into a single table to get PY AMT, using Join and Concatenate, but didn't get expected results.

Appreciate any insights on the approach to do this.

Source Data

TDATEACCOUNTAMOUNT
1/1/2012A CONSUMER INVESTMENT14
1/1/2012B CONSUMER INVESTMENT157
1/1/2012C CONSUMER INVESTMENT351
1/1/2012D CONSUMER INVESTMENT25
1/1/2012E CONSUMER INVESTMENT13
1/1/2012F CONSUMER INVESTMENT28
1/1/2012G CONSUMER INVESTMENT49
1/1/2012H CONSUMER INVESTMENT0
1/1/2011A CONSUMER INVESTMENT7
1/1/2011B CONSUMER INVESTMENT78.5
1/1/2011C CONSUMER INVESTMENT175.5
1/1/2011D CONSUMER INVESTMENT12.5
1/1/2011E CONSUMER INVESTMENT6.5
1/1/2011F CONSUMER INVESTMENT14
1/1/2011G CONSUMER INVESTMENT24.5
1/1/2011H CONSUMER INVESTMENT0

Expected Format

TDATEACCOUNTAMOUNTPY AMT
1/1/2012A CONSUMER INVESTMENT147
1/1/2012B CONSUMER INVESTMENT15778.5
1/1/2012C CONSUMER INVESTMENT351175.5
1/1/2012D CONSUMER INVESTMENT2512.5
1/1/2012E CONSUMER INVESTMENT136.5
1/1/2012F CONSUMER INVESTMENT2814
1/1/2012G CONSUMER INVESTMENT4924.5
1/1/2012H CONSUMER INVESTMENT00

    

Thanks,

Abhay

10 Replies
Not applicable
Author

hi

amhatre1

try this my example script below

maybe it helps for you

LOAD DATE,

     NAME,

     AMOUNT

FROM

(SAMPLE1);

Concatenate

LOAD AddYears(DATE,1) as DATE,

     NAME,

     AMOUNT as PY.AMOUNT

FROM

(SAMPLE2);

regard

GERNAN

Not applicable
Author

try this (see attached example)

MarcoARaymundo
Creator III
Creator III

Hi!

I'm not sure I understand what you want, but follows qvw for example.

Not applicable
Author

Hi,

Can you explain where py amount comes from or how it's calculated?

Thanks,

Matt

MarcoARaymundo
Creator III
Creator III

Matt, to summarize amount by account, just set the account as a dimension and amount as expression (Sum). like to pivot table in excel.

I hope have helped.

Not applicable
Author

HI , 

      Try the below code .

Tab1:

LOAD  ACCOUNT , max(TDATE) as TDATE , FirstValue(AMOUNT) as AMOUNT

From SourceData Group by  ACCOUNT Order by ACCOUNT,TDATE ;

Left Join

LOAD ACCOUNT ,[PY AMT];

LOAD  ACCOUNT , min(TDATE) as TDATE , FirstValue(AMOUNT) as [PY AMT]

From SourceData  Group by  ACCOUNT Order by ACCOUNT,TDATE desc; 

Please let me know if there is anything .

MarcoARaymundo
Creator III
Creator III

Matt, In your code to use order by ACCOUNT, TDATE, dont work, because Group only has the field ACCOUNT, in the left join the first load missing from sourcetable.

Sorry! But, i do not understand what you want to do, help me to help you.

you want the max and min value of the amount field per account, that's it?

If yes, use the qlikview functions, is easiest!

By reducing the load (GROUP BY), your data information is limited to a particular situation and restricts reuse.

Not applicable
Author

Hi,

It's not me that posted the question, I was asking him to define PY Amount in hopes of being able to create a chart with his requirements using set analyis.

It's Abhay that wrote the post.

Best,

Matt

Not applicable
Author