Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
HAMID_AKBARI
Contributor II
Contributor II

SUBFIELD and CountIF

I have a string column Location like A\B\C\..

using subfield i can split every part with delimeter  \

but this formula not working

=count(  {< subfield(Location ,'/',2)={'B'}>}   Item )

or

=count(  {< subfield(Location ,'/',2)={'B'}>}  subfield(Location ,'/',2) )

thanks in advance

Labels (2)
7 Replies
Chanty4u
MVP
MVP

try this

 

Sum({<Location={"=SubField(ActionCode,'/',2)" }>} Sales)

 

HAMID_AKBARI
Contributor II
Contributor II
Author

I need to count/sum  of all location which equal to string B for example

this work

=count(  {< location={'A\B\C'}>}   Item )

but

=count(  {< subfield(Location ,'/',2)={'B'}>}   Item )

has error

Chanty4u
MVP
MVP

did you tried this?

count({<Location={'B'},Location={"=SubField(ActionCode,'/',2)" }>} Item)

 

or

=count( {<Location={'B'} >} SubField(Location,'/',2)Item)

 

 

 

PrashantSangle

why don't you create flag in backend i.e. in script

and using that flag sum or count those location in front end

Try like 

 

Load text,if(SubField(text,'/',2)='B',1,0) as Location_B_Flag Inline[
text
A/B/C/
A/C
D/B
S/B/D
];

 

and in front end below expression is enough

=Count({<Location_B_Flag={'1'}>}text)

 

Regards,

 

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
HAMID_AKBARI
Contributor II
Contributor II
Author

Thanks for your answer but didnt work😔

HAMID_AKBARI
Contributor II
Contributor II
Author

honestly i am new to Qlik and  dont know how and where to put this code

Data is loading from SQL ODBC connection.

did you mean in the edit script section before load from SQL?

 

manoranjan_d
Specialist
Specialist

did you mean in the edit script section before load from SQL?

Yes, there you can create flag