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: 
mahendrankr
Contributor III
Contributor III

Nested if in a line chart

hi team,

I am using the below expression in a line chart. I get the trend line if I select only one channel, however if i select multiple channels, the chart is simply blank. pl help me solve this.

if(Channel='AMS',Sum({$<Variables={"ams_direct_cost"}>}Values),
if(Channel='GCM',Sum({$<Variables={"gcm_direct_cost"}>}Values),
if(Channel='FB',Sum({$<Variables={"fb_direct_cost"}>}Values),
if(Channel='ISG',Sum({$<Variables={"isg_direct_cost"}>}Values)))))

regards, mahe

5 Replies
PradeepK
Creator II
Creator II

Create Text object and add below measure; Just for your reference and Understanding..

Concat(distinct Channel, ',')

It's giving Null for Multiple Channel selection because none of the IF condition is satisfied and there is no ELSE condition for last statement.

Tip: Avoid nested if; look into Pick & Match approach.

mahendrankr
Contributor III
Contributor III
Author

hi pradeep,

thanks for the prompt reply. Yes i usually try my expressions in the text object. I tried using Pick & Match . Ref below. I am not able to solve it yet. Can you pl help me fix this.

Pick(match('AMS','GCM','FB','ISG'),
Sum({$<Variables={"ams_direct_Impressions"}>}Values),
Sum({$<Variables={"gcm_direct_Impressions"}>}Values),
Sum({$<Variables={"fb_direct_Impressions"}>}Values),
Sum({$<Variables={"isg_direct_Impressions"}>}Values))

thanks, mahe

Anil_Babu_Samineni

What is the definition for this? "Variables"

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
mahendrankr
Contributor III
Contributor III
Author

Hi Anil,


The variables are list of fields like ams, gcm, fb which is loaded as a crosstable.

Below is the load script. Is crosstable causing this issue.

Main:
CrossTable(Variables,Values,5)
LOAD
*
FROM [lib://Input File-MMM (code1_*******)]
(ooxml, embedded labels, table is [Input file]);

Anil_Babu_Samineni

I can understand that you have field and in it there are variable. But, If you can share the definition of variables we can understand that. Are they filed names?

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