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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Count items group by name based on status

Hi,

I have a table of items with status 'Missing' or 'Installed'. Simplified table below:

NameStatus
AMissing
BInstalled
BInstalled
CMissing
CInstalled

How can I achieve this calculation of total installed and missing items?

NameTotalInstalledMissing
A101
B220
C211

I managed to get the correct numbers but am not able to display it in the way I want to (as above) with the following codes

hostnameTotals:

Load "Host Name",

count(distinct %PWID) as "PW.Total"

Resident tempTable

group by "Host Name";

hostnameInstalled:

Load "Host Name",

if([PW.Status] like 'Installed', count(distinct %PWID)) as "PW.Installed",

    if([PW.Status] like 'Missing', count(distinct %PWID)) as "PW.Missing"

Resident tempTable

group by "Host Name", [PW.Status];

1 Solution

Accepted Solutions
OmarBenSalem
Partner - Champion II
Partner - Champion II

Don't alter ur source;

juste in your sheet, create a pivot table:

Capture.PNG

As a dimension: Name

As a measure: count(Status) or count(Distinct Status) ; depends on what u want to show

then add a column : Status

Capture.PNG

Lastly, activate the totals on the Status column:

Capture.PNG

result:

Capture.PNG

View solution in original post

7 Replies
OmarBenSalem
Partner - Champion II
Partner - Champion II

Don't alter ur source;

juste in your sheet, create a pivot table:

Capture.PNG

As a dimension: Name

As a measure: count(Status) or count(Distinct Status) ; depends on what u want to show

then add a column : Status

Capture.PNG

Lastly, activate the totals on the Status column:

Capture.PNG

result:

Capture.PNG

Anonymous
Not applicable
Author

was thinking too much and didn't think of using a pivot table haha thank you!!

Best Regards

Serena

Anonymous
Not applicable
Author

What if I want to calculate Installed/Totals? Can I do this in the pivot table?

OmarBenSalem
Partner - Champion II
Partner - Champion II

can you maybe show me with an image how u want to show this?

Anonymous
Not applicable
Author

Example:

NameTotalsInstalledMissingCompliance %
A1010 (0/1*100)
B220100 (2/2*100)
C21150 (1/2*100)

Compliance % = Installed / Total * 100

OmarBenSalem
Partner - Champion II
Partner - Champion II

If u wanted to be exactly as follow:

u'll have to do like this (but then , you won't be able to filter this table by Status...)

So create a pivot table:

as Dimension: Name

As column: =ValueList('Totals','Installed','Missing','Compliance%')

As a measure:

if(ValueList('Totals','Installed','Missing','Compliance%')='Totals', num(count(Status),'# ##0'),

if(ValueList('Totals','Installed','Missing','Compliance%')='Installed', num(count({<Status={'Installed'}>}Status),'# ##0'),

if(ValueList('Totals','Installed','Missing','Compliance%')='Missing', num( count({<Status={'Missing'}>}Status),'# ##0') ,

if(ValueList('Totals','Installed','Missing','Compliance%')='Compliance%', num((count({<Status={'Installed'}>}Status)/Count({<Name=,Status>}Status)),'# ##0,00%')

))))

Result:

Capture.PNG

OmarBenSalem
Partner - Champion II
Partner - Champion II

Or you can have sthing like this:

as dimension : Name

as column: Status

as measures:

count( Status)

count(Status)/count(total <Name> Status)

and activate totals on the column Status:

result:

Capture.PNG