Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
prasadcm
Creator II
Creator II

If else condition in variable

Hi,

I have an expression

=sum({<Distribution={1},[Task Category]={"ERP","Global versions"},

[Task Status]={'Completed', 'Warning'}>}

(if([Task Name]='AP Explorer_SAN',1,if([Task Name]='GM and OP analysis light',1,if([Task Name]='FMG Explorer_SAN',1,if([Task Name]='Reload of Quotation Hit Rate',1,

if([Task Name]='Reload of Sales Variance',1,

if([Task Name]='Reload of Service lead time',1,if([Task Name]='Reference List',1,if([Task Name]='Reload of GL line items',1,if([Task Name]='SO Condition Type',1,

if([Task Name]='Inventory report_SAN',1,

if([Task Name]='Reload of Freight report',1,if([Task Name]='Customer Statistics Finland',1,

if([Task Name]='Macgregor Migrated Project Life Explorer',1,

if([Task Name]='Material Delivery Status',1,

if([Task Name]='CashFlow_SAN',1,

if([Task Name]='Production Order Dashboard',1,

if([Task Name]='Production Order',1,

if([Task Name]='Purchase Orders new Report  Reload',1,

if([Task Name]='Reload Equipment Lead Time',1,

if([Task Name]='Customs reporting Malaysia',1,

if([Task Name]='Parts - Sales Dashboard_SAN',1,

vReloadDailyCount)))))))))))))))))))))))

wherein in if else condition i have task name,1 is the reload frequency(which is once a day for the mentioned apps) & vReloadDailyCount is 2(twice a day for other apps)


now this if else part is used in many places,so i want to put this if condition part in variable or some other way so that i do@nt have to repeat this part everywhere.


How am i supposed to do this?

Regards,

Prasad Mayekar

3 Replies
RonaldDoes
Partner - Creator III
Partner - Creator III

Hi Prasad,

You can open the variable overview by pressing CTRL+ALT+V and add a new variable there.

Choose a name, and use that wherever you'd like.

Anil_Babu_Samineni

Rather create in script which called If ...Else.... Statement and the give it as 1 , 0

Then, Use set analysis something like below

=sum({<Distribution={1},[Task Category]={"ERP","Global versions"}, FlagName = {1},

[Task Status]={'Completed', 'Warning'}>} vReloadDailyCount)

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
effinty2112
Master
Master

HI Prasas,

The suggestions you've been given are good ones and my suggestion is that your expression may be easier to maintain if written as:

=sum({<Distribution={1},[Task Category]={"ERP","Global versions"},

[Task Status]={'Completed', 'Warning'}>}

if(Match(

[Task Name],

'AP Explorer_SAN',

'GM and OP analysis light',

'FMG Explorer_SAN',

'Reload of Quotation Hit Rate',

'Reload of Sales Variance',

'Reload of Service lead time',

'Reference List',

'Reload of GL line items',

'SO Condition Type',

'Inventory report_SAN',

'Reload of Freight report',

'Customer Statistics Finland',

'Macgregor Migrated Project Life Explorer',

'Material Delivery Status',

'CashFlow_SAN',

'Production Order Dashboard',

'Production Order',

'Purchase Orders new Report  Reload',

'Reload Equipment Lead Time',

'Customs reporting Malaysia',

'Parts - Sales Dashboard_SAN')

,1,2))

I've replaced $(vReloadDailyCount) with 2.

Not so many brackets to keep track of. The if(match(...)) part of this expression can be used in the script as well as the interface.

Kind regards

Andrew