Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
Qlik Analytics Tour 2020 Online. Begins August 10th. Register Today
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Partner
Partner

If Else condition

Hi Team,

This could look simpler, but somehow I am stuck to get the logic. Can some one please help here? 

Requirement

If any User has an ID as 'C' - then the Role would be 'Manager'. At same time the all Zones would be falling under Role = 'Manager'.

If the User does not have an ID as 'C' , then the Role would be 'Sales Rep'.

Sample Data-

UserIDZone
JohnANorth
JohnBSouth
JohnCEast
JohnDWest
MaryANorth
MaryBSouth
MaryDWest
BobANorth
BobCEast
RichCEast
LucyANorth
LucyBSouth

 

Expected Output - 

UserIDZoneRole
JohnANorthManager
JohnBSouthManager
JohnCEastManager
JohnDWestManager
MaryANorthSales Rep
MaryBSouthSales Rep
MaryDWestSales Rep
BobANorthManager
BobCEastManager
RichCEastManager
LucyANorthSales Rep
LucyBSouthSales Rep

 

Regards!

Labels (2)
1 Solution

Accepted Solutions
Highlighted

Re: If Else condition

May be this

Table:
LOAD * INLINE [
    User, ID, Zone
    John, A, North
    John, B, South
    John, C, East
    John, D, West
    Mary, A, North
    Mary, B, South
    Mary, D, West
    Bob, A, North
    Bob, C, East
    Rich, C, East
    Lucy, A, North
    Lucy, B, South
];

Left Join (Table)
LOAD If(SubStringCount('|' & Concat(DISTINCT ID, '|') & '|', '|C|') = 1, 'Manager', 'Sales Rep') as Role,
	 User
Resident Table
Group By User;

View solution in original post

6 Replies
Highlighted

Re: If Else condition

May be this

Table:
LOAD * INLINE [
    User, ID, Zone
    John, A, North
    John, B, South
    John, C, East
    John, D, West
    Mary, A, North
    Mary, B, South
    Mary, D, West
    Bob, A, North
    Bob, C, East
    Rich, C, East
    Lucy, A, North
    Lucy, B, South
];

Left Join (Table)
LOAD If(SubStringCount('|' & Concat(DISTINCT ID, '|') & '|', '|C|') = 1, 'Manager', 'Sales Rep') as Role,
	 User
Resident Table
Group By User;

View solution in original post

Highlighted
Partner
Partner

Re: If Else condition

Hi,

try with something like this

Left Join
LOAD Distinct
User,
'Manager' as Role
Resident table
Where ID='C'
;

NoConcatenate
output:
LOAD
User,
ID,
Zone,
If(Len(Role)=0,'Sales Rep',Role) as Role
Resident table;

DROP Table table;

Highlighted
Partner
Partner

Re: If Else condition

Hi @sunny_talwar ,

 

Thank you for the logic. This has helped in getting the desired results. 

Even if I select the Role = 'Manager', that doesnt filter out the Zone as East and shows all Zones.

 

Regards!

 

Highlighted
Partner
Partner

Re: If Else condition

Hi @StarinieriG ,

 

Thank you for supporting. 

However, this again filters out the Zone values when Role is selected. 

If I select the Role = 'Manager', that filters out the Zone as East and other Zones are greyed out. The desired output has to show all Zones available for that User.

Highlighted

Re: If Else condition

Is this a question or a statement?

"Even if I select the Role = 'Manager', that doesnt filter out the Zone as East and shows all Zones."

Highlighted
Partner
Partner

Re: If Else condition

Hi @sunny_talwar ,

Sorry for the confusion.

That was the statement, and solution working as desired.

The requirement was NOT to filter out the East Zone only, rather show all 4 Zones , when Manageris selected. So its working proper.

Thanks again!