Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to do cumulative sum for two dimension

Hi,

I would like to ventilate this   calculation "=sum({$<FlagOuvertFerme={'Ouverture'}>}CompteurTicket)- sum({$<FlagOuvertFerme={'Fermeture'}>}CompteurTicket)" on two dimensions  "month- year" and "status"


When i use on dimension  "month-year" and full accumulation  it's work




ph1.JPG

ph2.JPG

but when  i inserted  dimension of status,  it's not good, numbers are different

ph3.JPG

Can you help me?

Thank you

12 Replies
Anonymous
Not applicable
Author

Hello,

In fact, the problem was the lack of data on every month. I had to force data to zero on the missing months on the script. Like this.


my source table is  "CONCAT_OUVERT_FERME"

and my axes are   :   Statut', 'Source_Code



Left join(CONCAT_OUVERT_FERME)

load

[id requesttypes] as 'Source_Code',

[Source de la demande] as 'Source_Lib'

Resident [Type de requete];

wrk_statut0:

load Distinct

Statut  as S_L

resident CONCAT_OUVERT_FERME ;

wrk_statut1:

load Distinct

S_L,

'0' as [Additional Field]

Resident wrk_statut0;

wrk_date0 :

load Distinct

Date as d,

MakeDate(year(Date),month(Date),1) as Date1

resident CONCAT_OUVERT_FERME ;

wrk_date1 :

load Distinct

Date1

resident wrk_date0 ;

wrk_date2 :

load Distinct

Date1,

'0' as [Additional Field]

resident wrk_date1 ;

wrk_source0 :

load Distinct

Source_Code  as S_C

resident CONCAT_OUVERT_FERME ;

wrk_source1 :

load Distinct

S_C,

'0' as [Additional Field]

resident wrk_source0 ;

Left join (wrk_source1)

load *

Resident wrk_date2;

Left join (wrk_source1)

load *

Resident wrk_statut1;

Left join (wrk_source1)

load

[id requesttypes] as S_C,

[Source de la demande] as Source_Lib

Resident [Type de requete];

CONCAT_OUVERT_NUL:

Load

'0' as 'id tickets',

'0' as 'CompteurTicket',

date(Date1,'DD/MM/YYYY') as Date,

year(Date1)&subfield(date(Date1,'DD/MM/YYYY'),'/',2) as MonthNum,

year(Date1) as Année,

month(Date1) as Mois,

day(Date1) as Jour,

year(Date1)&'-'&month(Date1) as MonthYear,

S_L as 'Statut',

S_C as 'Source_Code',

'Ouverture' as 'FlagOuvertFerme',

Source_Lib

resident wrk_source1;

drop Tables wrk_date0,wrk_date1,wrk_date2,wrk_statut0,wrk_statut1, wrk_source0,wrk_source1;



I hope it will help you



Regards,

Anonymous
Not applicable
Author

This information is important to take into account for future solutions, quite common these drawbacks.

Thanks for the solutions

venkatesan_e
Partner - Contributor
Partner - Contributor

Hi Sunny,

I have problem with cumulative sum for multiple dimension,

YearMonth,SKU group,Sku and etc.

for 1st month same value, when coming to 2nd month cumulative no previous month skugroup and SKU.

Yearmonth, Counts, Cumulative

01  10000, 10000

02 5000,15000

03 2000,17000

Cumulative will happen based on skugroup, SKU - month on Month.

if you have time can you help in this in script level