Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
QlikWorld 2020: Join us May 11 - 14, 2020 in Phoenix, AZ. Register early and save $400. Learn More
Highlighted
mrjohn23
Contributor III

Expression In Script

I have the below expression in the chart properties and I would like to add in the scrip. Can someone show me the best approach?

Expression in Chart - count({<Status={[Pended]}>}distinct ID)

how would that look in the scrip? Can I use a IF Statement, this is what I have below...


    
Count(IF(Status= 'Pended','')) as TotalPends

Tags (2)
1 Solution

Accepted Solutions

Re: Expression In Script

24 Replies

Re: Expression In Script

May be something like this:

LOAD Count(Status),

          ChartDimensions

Resident ...

Group By Chart Dimensions

Where Status = 'Pended';

MVP
MVP

Re: Expression In Script

Yes but don't forget to use Group By in your script..

mrjohn23
Contributor III

Re: Expression In Script

Count(IF(Status= 'Pended',distinct ID ) as TotalPends

I want to count distinct ids when a status = pended

Not sure how that would look in the script

MVP
MVP

Re: Expression In Script

Data:

Load * From TableName;

Count:

Load COUNT(Distinct ID) as TotalCount;

Load ID Resident Data Where Status = 'Pended';

Re: Expression In Script

And if there is a particular dimension on which you want the count, then may be this:

Data:

Load * From TableName;

Count:

Load   Dimension,

          COUNT(Distinct ID) as TotalCount;

Load ID Resident Data

Group By Dimension

Where Status = 'Pended';

mrjohn23
Contributor III

Re: Expression In Script

I'm hoping the expression can be created within the initial load with Ifs

I have...

Table:

Load

xxxx,xxxx,xxx,xxx

//(Hundereds of Columns)

Count(distinct ids) as TotalIds,

Count(DISTINCT if(Status='Pended')) as TotalPends , (The syntax is not right)

xxxx

FROM

Group by

xxxx,xxxx,xxx,xxx xxxx;

Re: Expression In Script

I think it would be better to left join your result back to the original table, because I don't think this would work the way you are doing:

1st of all are you doing a overall count of ids where status is pending? or on a particular dimension or dimensions?

mrjohn23
Contributor III

Re: Expression In Script

I'm trying to remove the expression that's in my chart count({<Status={[Pended]}>}distinct ID) and add into my script as an If statement but it seems that's not the best approach and may not be possible. 

Re: Expression In Script

What are the dimensions you are using in the chart?