Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Zaga_69
Creator
Creator

If wih multiples conditions

Hi dear all,

I ma trying to fix the following condition for a reference line a  Bar chart.

=if(Company='HMG' and [Creation Year]='2018',0.5,0)

However it does not work.

Any idea?

Thanks!

Edi

Labels (1)
3 Replies
Zaga_69
Creator
Creator
Author

Hi all,

I tried the following code line and works:

IF(Company='HMG' and [Creation Year]=2018 , 0.59,0)

However what I would like to do is creating two references lines when users select Company and Creation Year. I realized that I can create multiple Reference Lines by just adding a new reference line "Add reference Line". 

IF(Company='HMG' and [Creation Year]=2018 , 0.68,0)

reference line.PNG

In my case it is not a solution because when the user select another company , I will have the another reference lines as well. 

 What I need is to add two reference lines depending on the Company and Creation Year.

 

Any Idea?

 

Many Thanks!

 

Edi

marcus_sommer

I think you could just nest your conditions like:

if(company = 'a' and year = 2018, x,
   if(company = 'b' and year = 2018, y, z))

and you might also include a further check if the companies are external/internal, with getselectedcount() the number of selected values and many more, whereby by a larger number of conditions it might be easier to add these data within the datamodel instead of using very deep if-constructs.

- Marcus

Zaga_69
Creator
Creator
Author

Hi Marcurs!

Thank you.

What I have done was to build two Line References following your code:

External

if(Company ='HMH' and [Creation Year]=2018, 0.14,
if(Company ='HMG' and [Creation Year]=2018, 0.59,
if(Company ='HMN' and [Creation Year]=2018, 0.14,0)))

Internal

if(Company ='HMH' and [Creation Year]=2018, 0.68,
if(Company ='HMG' and [Creation Year]=2018, 0.35,
if(Company ='HMN' and [Creation Year]=2018, 0.24,0)))

 

In that way I have both references lines. it was the easier solution 🙂

I did get your idea with getselectedcount() 😕

Best regards!

Edi