Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
kavita25
Partner - Specialist
Partner - Specialist

How to show repeat purchase..

Hi Everyone,

I want to show those customers who was repeated in next month..

stalwar1gwassenaar

Please help me with this issue..

Its really very very urgent....

Regards,

Kavita

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Search the forum for NEW, LOST, RETURNING customers, it seems you want to show something like this.

There are multiple approaches, if you want to compare fixed periods, you can also try set analysis: For example, to show outlets that had no sale in max month but sale in max month -2, something like

=Count(

{<[DMS Outlet Code] =

     e({<InvMonth = {"=InvMonth=$(=Max({1}InvMonth))"}>})*p({<InvMonth = {"=InvMonth=$(=Max({1}InvMonth))-2"}>} )

>}

DISTINCT [DMS Outlet Code])

View solution in original post

22 Replies
Gysbert_Wassenaar

Create a new table in your script from the first one and then drop that first table:

_tempTable:

load *,

Year(InvoiceDate)*12+ Month(InvoiceDate) as MonthCounter,

Month(InvoiceDate) as InvMonth,

Year(InvoiceDate) as InvYear;

LOAD

     ...some fields...

     [DMS Outlet Code],

     ...some more fields...

     Date(Date#(InvoiceDate,'DD MMM YYYY'),'DD/MM/YYYY') as  InvoiceDate,            

     ...rest of the fields...

FROM

  [c249529.qvd]

  (qvd)

  ;

Result:

LOAD

  *,

  If(Previous(MonthCounter)=MonthCounter+1,1,0) as IsReturning

RESIDENT

  _tempTable

ORDER BY

    [DMS Outlet Code],

    InvoiceDate desc

  ;

DROP TABLE _tempTable;

Then you can use this expression: Count({<IsReturning={1}>}DISTINCT [DMS Outlet Code])


talk is cheap, supply exceeds demand
swuehl
MVP
MVP

I think there is a factor missing in MonthCounter calculation to create unique and consecutive numbers:

Year(InvoiceDate) *12+ Month(InvoiceDate) as MonthCounter,

Gysbert_Wassenaar

You're completely right. Didn't copy it correctly from my workbook. Thanks!


talk is cheap, supply exceeds demand
kavita25
Partner - Specialist
Partner - Specialist
Author

Thank You Gysbert...

I just have a doubt, if i want to show same thing for next  3 months...

For an e.g :

There's as Sale for May, Jun and Sep..

So for the Month of May and Jun should be count of 1..but not for Sep..as its next any of the next three months doesn't have sale.

It means the month itself should have sale and in any of the next three month should have sale..

Kindly guide me...

gwassenaarstalwar1swuehl

Regards,

Kavita



kavita25
Partner - Specialist
Partner - Specialist
Author

Please help me with this isuee...

Its really very very urgent.

swuehl
MVP
MVP

It might be urgent for you, this does not imply that it's urgent for us, on a weekend ...

Maybe something like attached:

Binary 'Test (49).qvw';

NewMaster:

LOAD *,

  AutoNumberHash128(  [DMS Outlet Code], MonthCounter) as Key;

LOAD *,

  MonthName(MakeDate(InvYear, InvMonth)) as InvMonthName,

  Year(InvoiceDate)*12+ Month(InvoiceDate) as MonthCounter

Resident UCMaster;

DROP TABLE UCMaster;

TMP:

LOAD DISTINCT

  Key,

  MonthCounter,

  [DMS Outlet Code]

RESIDENT

  NewMaster;

 

Result:

LOAD 

  Key,

    If(Previous(MonthCounter)=MonthCounter+1 and  [DMS Outlet Code] = Previous( [DMS Outlet Code]),Rangesum(Peek(ReturningIn),1),0) as ReturningIn

RESIDENT TMP

ORDER BY

    [DMS Outlet Code],

    MonthCounter desc   

  ;

  DROP Table TMP;

exit script;

Now you can filter the records to show only codes with at least N appearances in directly following months like

=Count({<ReturningIn ={">=3"}>}DISTINCT [DMS Outlet Code])

kavita25
Partner - Specialist
Partner - Specialist
Author

Hi,

Its showing only for Aug..it should show sale for that particular Month...and in next 3 month sale..

3 month sale is like it can be any month..

For.e.g Aug, Oct Dec..

Aug is the month,next 3 month sale is Sep Oct Nov...in oct it has sale..so it should be consider..

there's no compulsion that it sholud have sale for all the next 3 months...there will be OR condition..

kavita25
Partner - Specialist
Partner - Specialist
Author

Thank You so much for ur reply...

swuehl
MVP
MVP

Ok, if you need an or logic:

Result:

LOAD

  Key,

    If(Previous(MonthCounter) = MonthCounter+1 and  [DMS Outlet Code] = Previous( [DMS Outlet Code]),1,0) as ReturningIn1,

    If(Match( Previous(MonthCounter)- MonthCounter,1,2) and  [DMS Outlet Code] =  Previous([DMS Outlet Code]),1,0) as ReturningInAny2,

    If(Match( Previous(MonthCounter)- MonthCounter,1,2,3) and  [DMS Outlet Code] = Previous([DMS Outlet Code]),1,0) as ReturningInAny3

RESIDENT TMP

ORDER BY

    [DMS Outlet Code],

    MonthCounter desc  

  ;