Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
demcug82
Contributor III
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.

1 Solution

Accepted Solutions
demcug82
Contributor III
Contributor III
Author

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;

View solution in original post

6 Replies
Peter_Cammaert
Partner - Champion III
Partner - Champion III

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
Champion III
Champion III

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;

Anil_Babu_Samineni

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;

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
Peter_Cammaert
Partner - Champion III
Partner - Champion III

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

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

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;