Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

demcug82
New Contributor III

If and Or Condition on Scripting

Hi All,

I have a problem with an modify on a dashboard.

I have two fields:

Area and Market

For Area "Nordics and Baltics" and Market "Sweden" i have to insert "Branches",

For others Market of Nordics and Baltics i have to insert "Importers".

To semplify the qvw i have created a small file with inline script and Market Sweden and Finland.

I have replicated the tab of scripting where i have to apply the modify.

The target it's this:

Screen.png

In attachment the small file .qvw

Thanks and Regards,

Demetrio

EDIT:

In attachment the original script code to modify.

Tags (3)
1 Solution

Accepted Solutions
demcug82
New Contributor III

Re: If and Or Condition on Scripting

Ok i solved.

I have inserted in Main Table (data) a field Area&Market as Area_Market and then i joined with this new field.

LOAD Distinct

  Area_Market,

  Market as Market1,

  if(Area='Austria' OR Area='Benelux' OR Area='Denmark' OR Area='France' OR Area='Germany' OR Area='Iberia' OR Area='Italy' Or (Area='Nordics & Baltics' and Market='Sweden')  OR Area='Poland' OR Area='UK Ireland', 'Branches',

 

  

  if(Area='Balkans' OR Area='Central Eur Distr' OR Area='Eastern Eur Distr' or Area='South Eur Distr' Or (Area='Nordics & Baltics' and Market<>'Sweden')  or Area='Ukraine  Moldova', 'Importers')) as main_area

Resident data;

6 Replies

Re: If and Or Condition on Scripting

It's not entirely clear what you are trying to accomplish...

Branches & Importers, are they separate fields whose values you want to show in the same coilumn depending on the Market value?

vishsaggi
Esteemed Contributor III

Re: If and Or Condition on Scripting

Try this?

data:

LOAD * INLINE [

    Area, Market

    Nordics & Baltics, Sweden

    Nordics & Baltics, Finland

];

NoConcatenate

FINAL:

load

Area,

Market,

if(Market = 'Sweden' AND Area = 'Nordics & Baltics', 'Branches', 'Importers') AS MainArea

//if(Market = 'Finland' AND Area = 'Nordics & Baltics','Importers')) as mainArea

Resident data;

Drop Table data;

Re: If and Or Condition on Scripting

May be here

data:

Load * Inline [

Area, Market

Nordics & Baltics, Sweden

Nordics & Baltics, Finland

];

datap:

Load

Area,

Area as mainArea

Resident data;

Concatenate (datap)

load

Area,

if(Market = 'Sweden' and Area = "Nordics & Baltics",'Branches','Importers') as mainArea

Resident data;

Re: If and Or Condition on Scripting

Ah, you picture explains it. You want to include Sweden in the Importers area, but not in the Branches range and vice versa.

How about:

data:

LOAD * INLINE [

Area, Market

Nordics & Baltics, Sweden

Nordics & Baltics, Finland

];

LEFT JOIN (data)

LOAD Market,

     IF (Market = 'Sweden', pick(IterNo(), Area, 'Branches'),

                            pick(IterNo(), Area, 'Importers')) AS mainArea

RESIDENT data

WHILE IterNo() <= 2;


[Edit]: made it match your picture...

demcug82
New Contributor III

Re: If and Or Condition on Scripting

Ty All but again don't works.

In the first post i have inserted the original script code to modify.

I have not only one area (Nordics & Baltics).

Initially all Area Nordics & Baltics was Branches.

Now only Sweden (of Nordics & Baltics) must be branches.

But we have others area importers or Branches.

Demetrio

demcug82
New Contributor III

Re: If and Or Condition on Scripting

Ok i solved.

I have inserted in Main Table (data) a field Area&Market as Area_Market and then i joined with this new field.

LOAD Distinct

  Area_Market,

  Market as Market1,

  if(Area='Austria' OR Area='Benelux' OR Area='Denmark' OR Area='France' OR Area='Germany' OR Area='Iberia' OR Area='Italy' Or (Area='Nordics & Baltics' and Market='Sweden')  OR Area='Poland' OR Area='UK Ireland', 'Branches',

 

  

  if(Area='Balkans' OR Area='Central Eur Distr' OR Area='Eastern Eur Distr' or Area='South Eur Distr' Or (Area='Nordics & Baltics' and Market<>'Sweden')  or Area='Ukraine  Moldova', 'Importers')) as main_area

Resident data;