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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
santhoo_san
Partner - Creator II
Partner - Creator II

Creating a Table

Hi,

I have data as below:

DateCenterParticularAmount
01/01/20121Revenue150
01/01/20121Revenue100
01/01/20121Revenue225
01/01/20121Cost50
01/01/20121Cost75
01/01/20122Revenue80
01/01/20122Revenue30
01/01/20122Cost25
01/01/20122Cost15

with this data, I want to create / derive a table which should look as below:

DateCenterParticularAmount
01/01/20121Revenue150
01/01/20121Revenue100
01/01/20121Revenue225
01/01/20121Cost50
01/01/20121Cost75
01/01/20121Margin350
01/01/20122Revenue80
01/01/20122Revenue30
01/01/20122Cost25
01/01/20122Cost15
01/01/20122Margin70

Margin is calculated as Revenue minus Cost for a particular Center for a particular date.

Can some one help me in writing the script.

Thank you,

Santhosh

Labels (1)
1 Solution

Accepted Solutions
swuehl
Champion III
Champion III

Maybe like this?

TABLE:

LOAD Date,

     Center,

     Particular,

     Amount

FROM

[http://community.qlik.com/thread/62328?tstart=0]

(html, codepage is 1252, embedded labels, table is @1);

TMP:

LOAD Date, Center, sum(Amount) as Revenue

Resident TABLE where Particular = 'Revenue' group by Center, Date;

Concatenate LOAD Date, Center, sum(Amount) as Cost

Resident TABLE where Particular = 'Cost' group by Center, Date;

Concatenate (TABLE)

LOAD Date, Center, sum(Revenue) - sum(Cost) as Amount, 'Margin' as Particular

Resident TMP group by Center, Date;

drop table TMP;

View solution in original post

2 Replies
swuehl
Champion III
Champion III

Maybe like this?

TABLE:

LOAD Date,

     Center,

     Particular,

     Amount

FROM

[http://community.qlik.com/thread/62328?tstart=0]

(html, codepage is 1252, embedded labels, table is @1);

TMP:

LOAD Date, Center, sum(Amount) as Revenue

Resident TABLE where Particular = 'Revenue' group by Center, Date;

Concatenate LOAD Date, Center, sum(Amount) as Cost

Resident TABLE where Particular = 'Cost' group by Center, Date;

Concatenate (TABLE)

LOAD Date, Center, sum(Revenue) - sum(Cost) as Amount, 'Margin' as Particular

Resident TMP group by Center, Date;

drop table TMP;

santhoo_san
Partner - Creator II
Partner - Creator II
Author

Thank you Swuehl. It is working wonderfully.

Regards,

Santhosh