Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
nvijay5757
Creator
Creator

in place of IF condition can we write any other alternate

Hi,

i am writing the condition looks like 

=If(Program='1','23018_INTd_PHEV',
If(Program='2','23201_INTd_Gas 13 kph',
If(Program='3','23201_INTd_Gas 13 kph',
If(Program='4','24043_INTd_5Dr_Base_SS_Base',
If(Program='5','23653_INTd_RC_4x4_Gas_Common',
If(Program='6','23201_INTd_Gas 13 kph',
if(Program='7','23201_INTd_Gas 13 kph',
if(Program='8','23201_INTd_Gas 13 kph',
if(Program='9','23784_INTd_NE 13 kph','23006_INTd_Gas')))))))))

my dashboard is working fine.

but i have programs upto 30 programs are available. i need to do Automation.

with out writing if condition can we select Program filter to display the result. any other alternate method please suggest.

Thanks.

Labels (3)
1 Solution

Accepted Solutions
Andrei_Cusnir
Specialist
Specialist

Hello,

 

To simplify further your example and to avoid writing new nested if statements each time, you can follow the steps below:

 

1. Create a new load for the severities:

 

2. Now you can modify the charts as follows:

 

 

This method, doesn't require nested if statements, because:

  1. Num#(Replace('Severity1', 'Severity', '')) // Will convert Severity1, Severity2, Severity3 etc. to 1, 2, 3 etc.
  2. Pick(...) // Will return the needed expression based on the return from Nujm#(...)
  3. This means that if the Severity is 1, it will convert Severity1 to 1 and thus Min({<Description={'$(v23007)'}>}Min4) expression will be evaluated.

With this method, in case you need to add new severity, you just add it in the load script and then update the charts with additional line for the expression. Without needing to do if statements.

 

Your charts when Severity1 is selected:

 

My charts when Severity1 is selected:

 

As you can see they are the same so it is working!

 

I hope that this information is helpful.

 

Help users find answers! Don't forget to mark a solution that worked for you! 🙂

View solution in original post

6 Replies
Andrei_Cusnir
Specialist
Specialist

Hello @nvijay5757,

 

Perhaps the following use case scenario might help you:

 

1. You can load the ProgramNumber and ProgramCode as a value (Either with Load Inline statement or EXCEL file etc.):

 

2. After that I have loaded a demo dataset:

 

3. Now I want to create a measure that will show the ProgramCode. Instead of having multiple nested if statements as you have mentioned, I have used the following expression: SubField(Concat(ProgramCode, ','), ',', Program)

 

This expression will:

  • Concat(ProgramCode, ',') // Concatenate all the values in ProgramCode and will add a comma between them
  • SubField(...) // Will split the concatenated field by comma and Program will indicate which part of the split value you want to get

4. Outcome is:

 

NOTE: Since we have ProgramNumber associated with ProgramCode, you can also use this in other use case scenarios.

 

 

I hope that this information was helpful. In case I have misunderstood the use case scenario, please elaborate in details by providing additional information. However, if it has helped you resolve the issue, addressed your concerns or at least pointed you in the right direction, please mark it as Accepted Solution to give further visibility to other community members. 
 

Help users find answers! Don't forget to mark a solution that worked for you! 🙂
nvijay5757
Creator
Creator
Author

Hi,

Thanks for your reply.

i am attaching sample data and QVF can you please look into that and suggest.

in that two charts are showing data in that i have used if condition and variables.

main aim is with out writing if condition can we select Program filter to display the result.

like automation. if we add further multiple programs.

Thanks again.

Andrei_Cusnir
Specialist
Specialist

Hello,

 

To simplify further your example and to avoid writing new nested if statements each time, you can follow the steps below:

 

1. Create a new load for the severities:

 

2. Now you can modify the charts as follows:

 

 

This method, doesn't require nested if statements, because:

  1. Num#(Replace('Severity1', 'Severity', '')) // Will convert Severity1, Severity2, Severity3 etc. to 1, 2, 3 etc.
  2. Pick(...) // Will return the needed expression based on the return from Nujm#(...)
  3. This means that if the Severity is 1, it will convert Severity1 to 1 and thus Min({<Description={'$(v23007)'}>}Min4) expression will be evaluated.

With this method, in case you need to add new severity, you just add it in the load script and then update the charts with additional line for the expression. Without needing to do if statements.

 

Your charts when Severity1 is selected:

 

My charts when Severity1 is selected:

 

As you can see they are the same so it is working!

 

I hope that this information is helpful.

 

Help users find answers! Don't forget to mark a solution that worked for you! 🙂
nvijay5757
Creator
Creator
Author

Hi,

Thanks

can you please share app.

nvijay5757
Creator
Creator
Author

Hi,

Thanks.

1. in variable we have written if statement.

2. if any new program added then will add the description details every time.

3. our intention is to avoid every time description details.

Andrei_Cusnir
Specialist
Specialist

Hello,

Yes sure! Here is the app. I hope it helps

Help users find answers! Don't forget to mark a solution that worked for you! 🙂