Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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-
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 |
Expected Output -
User | ID | Zone | Role |
John | A | North | Manager |
John | B | South | Manager |
John | C | East | Manager |
John | D | West | Manager |
Mary | A | North | Sales Rep |
Mary | B | South | Sales Rep |
Mary | D | West | Sales Rep |
Bob | A | North | Manager |
Bob | C | East | Manager |
Rich | C | East | Manager |
Lucy | A | North | Sales Rep |
Lucy | B | South | Sales Rep |
Regards!
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;
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;
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;
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!
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.
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."
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!