Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
How can i find out that which value in a field is in the majority w.r.t the other values of that field? If i have to find out which gender is in majority, then how can i do it?
I am attaching the data file for the reference.
Hi abba,
check out this code script:
RawData:
LOAD NaFe,
Age,
Gender
FROM mock.xlsx (ooxml, embedded labels, table is Sheet1);
GndrCnt:
LOAD
Count(Gender) AS GndrCnt,
Gender
Resident RawData
Group By Gender
;
MaxCnt:
LOAD
max(GndrCnt) AS MaxCnt
Resident GndrCnt
;
Result:
LOAD
Gender AS Major
Resident GndrCnt
Where GndrCnt = peek('MaxCnt',0, 'MaxCnt')
;
// clean up
DROP Table GndrCnt, MaxCnt;
HtH
Roland