Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
Not applicable

Expression

Hi all,

I have 2 columns. ID and Value like below.

ID         Value

1245       10

1569        8

2145       15

2356       20

Sales = count of the "Value" that anything starts with number "1" in ID column.

Costs = count of the "Value" that anything starts with number "2" in ID column.

Can someone tell me how to write the expression.

Thanks

1 Solution

Accepted Solutions
qlikmsg4u
Valued Contributor

Re: Expression

=If(Left(ID,1)=1,Count(Value),Count(Value))

or

Sales : =If(Left(ID,1)=1,Count(Value))

Costs : =If(Left(ID,1)=2,Count(Value))

9 Replies

Re: Expression

try like this

sales :  if(ID like '1*',count(Value))

cost:  if(ID like '2*',count(Value))

qlikmsg4u
Valued Contributor

Re: Expression

=If(Left(ID,1)=1,Count(Value),Count(Value))

or

Sales : =If(Left(ID,1)=1,Count(Value))

Costs : =If(Left(ID,1)=2,Count(Value))

MVP
MVP

Re: Expression

Sales = count of the "Value" that anything starts with number "1" in ID column.

Costs = count of the "Value" that anything starts with number "2" in ID column.

count({$ <ID={"1*"}>} Value)

Re: Expression

try

Sales: count({<ID ={"1*"}>}Value)

Costs: count({<ID ={"2*"}>}Value)

Re: Expression

Hi

Try like this

Value:

LOAD *, Pick(WildMatch(ID, '1*', '2*'), 1, 2,3) AS Type INLINE [

    ID,Value    

    1245,10

    1569, 8

    2145,15

    2356,20

];

Sales =Sum({<Type = {1}>}Value)

Cost  =Sum({<Type = {2}>}Value)

Not applicable

Re: Expression

Thanks to both of you. Both expressions working fine.

Not applicable

Re: Expression

Thanks everyone.

Re: Expression

if you have got the answer please mark this thread as answer and close this thread ..so that it will be helpful for others

Arjunarao
Honored Contributor II

Re: Expression

One question, different answers. Nice.

Community Browser