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

How to LOAD attribute boolean values

Hi,

I am trying to create a table in QlikView, using attributes from an SQL database.

The table in the database is composed of "Boolean" values, which are shown as either "0" or "1".

I want to load, for example, only those data which have a value of TRUE  (meaning :  "1")

Here is my load script :

Customers :

LOAD

  personHasEmail,

  (personHasEmail = '1') as Email_YES

(Meaning :  ALL data, where the person has an email, will be taken from the database)

And, in QlikView, I have the following expressions :

Count (CustomerID)

Count(Email_YES)

(Each customer has a unique ID.  So, "Count CustomerID" will produce the total number of people in the database)

And, "Count(Email_YES") should display ONLY those people who have email addresses.

But, this is not working; 

Both expressions are displaying the TOTAL number of customers; 

Obviously, the Count(Email_YES) expression is not working. Instead of counting only those people with emails, it's counting everyone.

Any help would be greatly appreciated.

10 Replies
alexandros17
Partner - Champion III
Partner - Champion III

Try this:

Customers :

LOAD

  personHasEmail,

  If(personHasEmail = '1', 1, 0) as Email_YES

then use

Count({$<Email_YES={'1'}>} CustomerID)

let me know

Not applicable
Author

Thanks, Allesandro.

Unfortunately, the expression produced a zero  ("0") value.

awhitfield
Partner - Champion
Partner - Champion

Hi Stepen,

see the attached example:

Script

Data:
Load * Inline
[
Customer, EmailFlag
A,1
B,1
C,1
D,0
]
;

Expression in chart

Count(If(EmailFlag = 1, Customer))

HTH Andy

alexandros17
Partner - Champion III
Partner - Champion III

Could you share your doc (or a similar example) ?

Not applicable
Author

Hi Andy,

thanks for your reply.

I assume, from your example, I should replace Customer with CustomerID ?

And, EmailFlag..........with "PersonHasEmail"?

I did that.  And, I'm getting the same result :  zero (0)

Not applicable
Author

Sorry, which doc?

I'm new to this

You mean the results I am getting?

alexandros17
Partner - Champion III
Partner - Champion III

The qlikview file (.qvw)

awhitfield
Partner - Champion
Partner - Champion

HI Stephen,

the example was just to show the principle, upload your QVW please.

Andy

Gabriel
Partner - Specialist III
Partner - Specialist III

Hi,

I think you should just load everything as it is, and in your expression in UI, you can count where Email_Yes= 1.

As in

LOAD

  personHasEmail,

  personHasEmail  as Email_YES

From Source;

Then in your expression to count Email_Yes

Count({<Email_Yes = {1}>}   Email_Yes)

This is work and you can Count your customer ID as well.