Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

find the majority of a value in the field

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.

1 Reply
Not applicable
Author

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