6 Replies Latest reply: Jan 18, 2017 2:50 AM by Peter Kral

# Percentage comparison between months

Hi, please help me. I have this table and I need to compare amount of sales between months in percentage and then I need to make a chart from it. How can I do that?

PERIODSALES
201601256
201602263
201603486
201604156
201605848
201606564
201607452
201608489
201609856
201610485
201611523
201612875
• ###### Re: Percentage comparison between months

sum(SALES) / sum( Total SALES)

• ###### Re: Percentage comparison between months

I´m sorry, I have not expressed myself clearly. I need to show the percentage growth between months. Can you help me?

• ###### Re: Percentage comparison between months

May be like this:

Sum(SALES)/Above(Sum(SALES)) - 1

Update: Missed a closing parenthesis which I have added not in red

• ###### Re: Percentage comparison between months

Sum(SALES)/Above(Sum(SALES)

• ###### Re: Percentage comparison between months

Hi,

You can create a calendar like :

```LOAD Date#(PERIOD, 'YYYYMM') as _PERIOD, SALES INLINE [
PERIOD, SALES
201601, 256
201602, 263
201603, 486
201604, 156
201605, 848
201606, 564
201607, 452
201608, 489
201609, 856
201610, 485
201611, 523
201612, 875
];

SET vMinDate = 201601;
SET vMaxDate = 201612;

CAL:
Date#(\$(vMinDate)+RecNo()-1, 'YYYYMM') as _PERIOD,
Date#(\$(vMinDate)+RecNo()-1, 'YYYYMM') as PERIOD,
'M' as TYPE
AutoGenerate (\$(vMaxDate)-\$(vMinDate)+1)
;

Concatenate(CAL)
Date(AddMonths(Date#(_PERIOD, 'YYYYMM'), -1), 'YYYYMM') as _PERIOD,
PERIOD,
'M1' as TYPE
Resident CAL
;
```

And this expression :

Sum({<TYPE={'M'}>}SALES)

/ Sum({<TYPE={'M1'}>} SALES)

• ###### Re: Percentage comparison between months

Thank you very much, it works!