Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello Everyone,
I am new user / Developer of Qlik sense
I am facing problem while counting the Text strings , Please refer an attachment to know more about my data.
KPI Field is showing final output in attachment. KPI Calculation conditions mention below.
ex. if AA customer have 'Ext' flag for one month and remaining 11 months are no flags then that case is 'One-off'
if AA have flag atleast for two seperate month then case is 'Repeat'
if any one of have multiple flag in single month and remaining all months no flags then case is 'Single month'
if any one have flag at least five times out of last 6 months then its 'Regular'
Waiting for your valuable reply Guys.
Thanks.
Please adapt this to what u have:
t:
load year(date(date#(Date0,'M/D/YYYY'))) as Year, date(date#(Date0,'M/D/YYYY')) as Date, Month,"Customer Name",Result as ExpectedResult,
if(today()-date(date#(Date0,'M/D/YYYY'))<=360,1,0) as Flag6Months
Inline [
Date0,Month, Customer Name, Result
1/1/2018,18-Jan,A, Single Month
2/2/2018,18-Feb,B, Repeat
2/2/2018,18-Feb,C,One off
12/5/2018,18-Dec,D,Regular
11/5/2018,18-Nov,D,Regular
1/4/2018,18-Jan,A,Single Month
1/4/2018,18-Jan,A,Single Month
3/2/2018,18-Mar,B,Repeat
10/2/2018,18-Oct,D,Regular
9/2/2018,18-Sep,D,Regular
8/2/2018,18-Aug,D,Regular
];
left join(t)
load Year, "Customer Name", count(Month) as NbMonths,count(DISTINCT Month) as NbDistinctMonths Resident t Group by Year,"Customer Name";
left Join(t)
load "Customer Name",Flag6Months,NbMonths,NbDistinctMonths
,if(NbMonths>1 and NbDistinctMonths=1,'Single Month',
if(NbDistinctMonths>1 and NbDistinctMonths<5,'Repeat',
if(NbDistinctMonths=1,'One off',
if(NbDistinctMonths>=5 and Flag6Months=1,'Regular')))) as CalculatedResult
Resident t;
Result:
Hi Omar,
Thank you for the swift reply. Let me check with my data.
Regards,
Yuva