Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to check based on condition and display related data?

Hi All,

Can any one help me to display all customer names whose available balance is less than minimum balance.

Ex: I  have 3 minimum balance w.r.t 3 Account type I want to check which customer maintain minimum balance w.r.t these 3 acc type and minimum balance value.

I am confused about the approach.. I have used variable  that holds total balance.. now I need to compare that with minimum balance and get corresponding customer name. what should be the expression? or approach?

Regards,

Prajna

13 Replies
sudeepkm
Specialist III
Specialist III

Let me know if you can use something like below: Suppose you have a customer table with

customernameavailablebalanceaccounttype
name110000current
name120000saving
name11000other
name215000current
name218000saving
name21200other

and another table to store the minimumbalance.

minbalcurrentminbalsavingsminbalother
10000200001000

In your load script you can create flags to indicate which customer has available balance below than minimumbalance based on the account type:

tmp:

LOAD minbalcurrent,

     minbalsavings,

     minbalother

FROM

customer.xlsx

(ooxml, embedded labels, table is minbal);

let vMinBalCurrent = peek('minbalcurrent',0,'tmp');

let vMinBalSaving = peek('minbalsavings',0,'tmp');

let vMinBalOther = peek('minbalother',0,'tmp');

DROP Table tmp;

customer:

LOAD customername,

     availablebalance,

     accounttype,

     if(accounttype='current' and availablebalance< '$(vMinBalCurrent)',1,0) as currentbalflag,

     if(accounttype='saving' and availablebalance< '$(vMinBalSaving)',1,0) as savingsbalflag,

     if(accounttype='other' and availablebalance< '$(vMinBalOther)',1,0) as otherbalflag

FROM

customer.xlsx

(ooxml, embedded labels, table is customer);

Now on the UI you can count the number of customers having available balance lesser than the minimum balance for specific account type just using the flags. Or you can display those customers name who has at least one of the flags as 1.

count({<savingsbalflag={1}  >} customername)

count({<currentbalflag={1}  >} customername)

count({<otherbalflag={1}  >} customername)

Not applicable
Author

Hi,

I have deposit and withdrawl column no available balance column as such. So I had created variable that takes sum(deposit)- sum(withdrawl) for selections done. Can u suggest what can be done in the scenario u mentioned?

Regards,

Prajna

sudeepkm
Specialist III
Specialist III

If you have two fields as deposit and withdraw then you can calculate the available balance per row in the script itself.

if(accounttype='current' and (deposit - withdraw)< '$(vMinBalCurrent)',1,0) as currentbalflag,

     if(accounttype='saving' and (deposit - withdraw)< '$(vMinBalSaving)',1,0) as savingsbalflag,

     if(accounttype='other' and (deposit - withdraw)< '$(vMinBalOther)',1,0) as otherbalflag

Not applicable
Author

I made corresponding changes and tried em getting error near if condition. Following is the code

SQL SELECT "Mini_FD",
                  "Mini_RD",
                     "Mini_SB"
FROM "Personal_Banking".dbo."Minimum_BalanceAmt";
let vMinBalFD = peek('Mini_FD',0,'tmp');
let vMinBalRD = peek('Mini_RD',0,'tmp');
let vMinBalSB = peek('Mini_SB',0,'tmp');
DROP Table tmp;
customer:
SQL SELECT "A_typeID",
   "Cust_Id",
if
(A_typeID= 1 and (Deposit_Amt - Withdrawl_Amt)< '$(vMinBalSB)',1,0) as FDbalflag,
  if(A_typeID=2 and (Deposit_Amt - Withdrawl_Amt)< '
$(vMinBalFD)',1,0) as savingsbalflag,
if(A_typeID=3 and (Deposit_Amt - Withdrawl_Amt)< '
$(vMinBalRD)',1,0) as RDbalflag
FROM "Personal_Banking".dbo."Bank_Tx";

Em new to this.. em not able to rectify the error. Can u suggest me what's the prob?

sudeepkm
Specialist III
Specialist III

I see there is a ' near the if statement can you pls remove that and try.

if(A_typeID= 1'  Remove this ' here

Not applicable
Author

yeah did that..  error is still the same..

Not applicable
Author

error.PNG.png

sudeepkm
Specialist III
Specialist III

Sorry pls disregard the previous message.

can you try something like below.

customer:

Load [A_typeID], [Cust_Id],

if([A_typeID]= 1 and ([Deposit_Amt] - [Withdrawl_Amt])< '$(vMinBalSB)',1,0) as FDbalflag,
  if([A_typeID]=2 and ([Deposit_Amt] - [Withdrawl_Amt])< '
$(vMinBalFD)',1,0) as savingsbalflag,
if([A_typeID]=3 and ([Deposit_Amt] - [Withdrawl_Amt])< '
$(vMinBalRD)',1,0) as RDbalflag;

SQL SELECT "A_typeID",
   "Cust_Id",

"Deposit_Amt", "Withdrawl_Amt" 
FROM "Personal_Banking".dbo."Bank_Tx";

Not applicable
Author

Hi,

Reload was successful. But if I take a chart to display em not able to get any info

I added just one count expression u had sent and used A_typeID as dimension

Regards,

Prajna