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

Announcements
April 13–15 - Dare to Unleash a New Professional You at Qlik Connect 2026: Register Now!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Same Store analysis - Count and Sales

Hi All,

I have a data set on which I need to do Same Store analysis..

Same Store are the stores having sales last year and this year..

below is the sample data

YearStore IdSales
2013123100
2013124200
2013125300
2013126400
2013127500
2013128600
2013129700
2012123800
2012125900
20121271000
2012128200
2011124300
2011123500
2011129580
2011125900
20101231000

so based on the above data set I need same store analysis as below:

YearSame Store CountSame Store Sales
201341500
201221700
20111500
201000

The above output is based on the stores have sales to there previous year

for 2013 -- store count =4 (123,127,125,128) and similarly sales =1500 (100+300+500+600)

for 2012 -- store count =2 (123,125) and sales = 1700 (800+900)

how can I achieve this in a straight table..

Thanks in advance.

Aashish

13 Replies
Anonymous
Not applicable
Author

Hi KC,

I want to calculate the count of those store which are active last year..

for example in stores in 2013 are (123,124,125,126,127,128)  but out of these store only 4 were active or having sales in last year so in year 2012 (123,125,127,128) that is why in 2013 the count is 4..

hope I am able to clear your doubt..

Anonymous
Not applicable
Author

hi Ruben,

Yes it was Typo.. I corrected it to 129..

I can't open your qvw since I am using personal edition.. could you post your solution here.

rubenmarin

Ok, expressions are simple: sum(SameStore) and sum(SameSales)

This is my script:

Initial:

LOAD * Inline [

Year,Store Id,Sales

2013,123,100

2013,124,200

2013,125,300

2013,126,400

2013,127,500

2013,128,600

2013,129,700

2012,123,800

2012,125,900

2012,127,1000

2012,128,200

2011,124,300

2011,123,500

2011,129,580

2011,125,900

2010,123,1000

];

Data:

NoConcatenate

LOAD Year,

    [Store Id],

    Sales,

    If(Previous([Store Id])=[Store Id] and Previous(Year)=Year-1, 1) as SameStore,

    If(Previous([Store Id])=[Store Id] and Previous(Year)=Year-1, Sales) as SameSales

Resident Initial

Order by [Store Id], Year;

DROP Table Initial;

sushil353
Master II
Master II

Hi Sharma,

Try below code:

Temp:

load Year&Store as Key,

Year,

Store,

Sales

from source_file;

left join

Load (Year+1)&Store as Key,

1 as SSFlag

Resident Temp;

now in the expression you can simply use this flag to count and get the sales.

count({<SSFlag={1}>}Store)

sum({<SSFlag={1}>}Sales)

HTH

sushil