Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
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
Specialist
Specialist

=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))

View solution in original post

9 Replies
avinashelite

try like this

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

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

qlikmsg4u
Specialist
Specialist

=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))

maxgro
MVP
MVP

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)

Kushal_Chawda

try

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

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

MayilVahanan

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)

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Not applicable
Author

Thanks to both of you. Both expressions working fine.

Not applicable
Author

Thanks everyone.

avinashelite

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

qlikviewwizard
Master II
Master II

One question, different answers. Nice.