Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

count & max

hi,

i have feild in the line order with value 1 or 2.

i want to calculte in%

exm:

order num 1 - i have 5 lines with 1 & 1 line with 2

order num 2 - i have 5 lines with 1 & 0 line with 2

order num 3 - i have 0 lines with 1 & 4 line with 2


i want to know in % how many orders have only 2 in that feild - in the exm 33%

how do i write it?

thanks'

yarin.

15 Replies
tresesco
MVP
MVP

Instead of writing the data in words, could you provide a sample of data? That would help us understand better.

Anonymous
Not applicable
Author

orderline ordertest field
111
121
131
141
151
162
212
222
232
241
251
312
322
332
342
352
362

how many orders have only 2 value on test field ?

tresesco
MVP
MVP

Try like:

Count( Distinct {<[test field]={2}>} order)

Anil_Babu_Samineni

Perhaps This:

Count( {<order = P({order = {'2'}}}), [test field]>} [test field])count & max

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
soloeeeoff
Contributor III
Contributor III

This Problem can only be solved by the load statements as follows..

tab1:

LOAD order,

     [line order],

     [test field]

FROM

(ooxml, embedded labels, table is Sheet1);

Solution for given data.PNGSolution for additional data.PNGScript.PNG

tab2:

load

  order as distinct_order,

  only([test field])as cnt

Resident tab1

Group by order

;

Jason_Michaelides
Luminary Alumni
Luminary Alumni

Try this:


Sum(Aggr(If(Concat(DISTINCT [Test field],',')=2,1,0),Order))


Hope this helps,


Jason

effinty2112
Master
Master

Hi Yarin,

                    Try this. It's similar to Anil's but I think we need to exclude line orders that have any test field = 1 rather than include any that have test field = 2.

=count({$<[line order]= E({<[test field] = {1}>})>}DISTINCT [line order])

EDIT : I think this is correct as we are trying to count order not line order.

=count({$<order= E({<[test field] = {1}>})>}DISTINCT order)

Kind regards

Andrew

Jason_Michaelides
Luminary Alumni
Luminary Alumni

Potential problem with this solution is it assumes 1 and 2 are the only possible values for the test field. If that's the case then great! 

effinty2112
Master
Master

"i have feild in the line order with value 1 or 2."