Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Pico
Partner - Creator
Partner - Creator

Getting the values from column B where column A is only of 1 type

Hi all,

this is my situation, I have two columns:

Name Object
Mark Pen
Mark Bottle
Mark Book
Lisa Book
Lisa Pen
Paul Pen

 

I would like to know how can I filter in order to obtain "The people that have ONLY a Pen" (in this case, Paul)

or "The people  that have ONLY book and pen" (Lisa)

The problem is that I have 10+ objects types and a LOT of people... and the possible combinations of filters are A LOT, so I would like to have something "structured"

How can I achieve this?

Thank you so much, have a nice day

 

Labels (2)
3 Replies
Aurelien_Martinez
Partner - Specialist II
Partner - Specialist II

Hi,

You can create a field in the dataoad script.

1. you count the number of object by name

2. if the number is 1 you add a value in the new field "Filter"

data:
LOAD
  *
Inline [
Name,	Object
Mark,	Pen
Mark,	Bottle
Mark,	Book
Lisa,	Book
Lisa,	Pen
Paul,	Pen
];

join(data)
LOAD
  Name,
  Count(DISTINCT Object) as nb_object
Resident data
Group by
  Name
;

LOAD
  Name,
  Object,
  If(nb_object=1, 'The people that have ONLY a ' & Object, Null()) as Filter
Resident data
;

DROP Table data;

 

Help users find answers! Don't forget to mark a solution that worked for you!
Pico
Partner - Creator
Partner - Creator
Author

Thank you.

Sadly this works well with only the first example. 

I have 10+ object types, and I will need also to answer to "show people that have only object 1, 4, 5, 13".

Aurelien_Martinez
Partner - Specialist II
Partner - Specialist II

Ok, sorry I didn't read all the problem ^^'

data:
LOAD
  *
Inline [
Name,	Object
Mark,	Pen
Mark,	Bottle
Mark,	Book
Lisa,	Book
Lisa,	Pen
Paul,	Pen
];

join(data)
LOAD
  Name,
  Count(DISTINCT Object) as nb_object,
  Concat(Object, ' and ') as Objects
Resident data
Group by
  Name
Order By
  Object
;

LOAD
  Name,
  Object,
  'The people that have ONLY a ' & Objects as Filter
Resident data
;

DROP Table data;

 

 

Help users find answers! Don't forget to mark a solution that worked for you!