Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
GOKULAKANNAN
Creator II
Creator II

How to find count of unique and duplicate values of a field

I have 3 fields (i.e customer ID,travel_route,prize) like below table

load * inline [

customer ID, travel_route, Prize

1, france,1000$

1,India,200$

1,USA,500$

2,sweden,400$

2,Netherland,600$

2,Finland,700$

3,Australia, 600$

3,Canada,300$

];

Now I need the count of the number of customer travelled (i.e. 3), and number of travel routes (3 for customer id 1, 3 for customer id 2 and 2 for customer id  3 ), could anyone please help with this query

Labels (1)
4 Replies
Taoufiq_Zarra

@GOKULAKANNAN  if I understand correctly

for the first:

=count(distinct [customer ID])

for the second [customer ID] as a dimension and count(distinct travel_route) as measure

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
sidhiq91
Specialist II
Specialist II

@GOKULAKANNAN  If you are looking something at the script level. You can try the below code.

NoConcatenate
Temp:
load * inline [
customer ID, travel_route, Prize

1, france,1000$

1,India,200$

1,USA,500$

2,sweden,400$

2,Netherland,600$

2,Finland,700$

3,Australia, 600$

3,Canada,300$
];

NoConcatenate
Temp1:
Load count(distinct [customer ID]) as Total_Customer
Resident Temp;

NoConcatenate
Temp2:
Load Count(distinct [travel_route]) as Total_travel_routes,
[customer ID]
Resident Temp
group by [customer ID];

Exit Script;

GOKULAKANNAN
Creator II
Creator II
Author

I just need to do this in script itself, i need only count

SunilChauhan
Champion II
Champion II

in KPI  Take Measure as count(distinct [customer ID]) And Label it to Total customer

now take a Bar 

in DImension Take CUstomerID

and In Measure

Count( distinct Route)  

see the attched file

Sunil Chauhan