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

Select Max Value from a list of values

Hi everyone,

I have a table with two dimensions (date and code) and one expression (value).

There are three distinct codes, RFN, NP, and PJ. Each code has a value. The value is a count of the number of times a code occurs on a specific date. I would like to select the max value from each code, and repeat it for the remaining codes on each date.

For example on 04-MAR-15 the max value is 5, so I would repeat 5 for each codes. On 06-MAR-15 the max value is 4 so I would like to repeat 4 for each code.

The table on left is what I currently have. The table on the right is what I'm trying to achieve (these are hard coded currently).

I've tried using the statement:

=if(CODE = 'NP' or CODE = 'PJ', count(distinct {$<prodtime_CODE ={"*"}-{'NP', 'PJ'}>} VALUE), count(distinct {$<CODE ={"*"}-{'NP', 'PJ'}>} VALUE))


but it removes the NP and PJ codes from the table.


Any ideas how I can accomplish this?

Thanks!

Michael

1 Solution

Accepted Solutions
JonnyPoole
Employee
Employee

My answer is as follows and attached

sum( total <Date,Code> Hours)

/

count(DISTINCT total <Date> Inits)

Capture.PNG

View solution in original post

12 Replies
Clever_Anjos
Employee
Employee

Try

MAX(TOTAL <Date> value)

Anonymous
Not applicable
Author

That removes everything from the table.

Clever_Anjos
Employee
Employee

Did I typed your field name correctly? value <> Value

Anonymous
Not applicable
Author

Yes, I typed in the field name correctly

JonnyPoole
Employee
Employee

max( total <Code> aggr( sum(Value),Code,Date) )

Clever_Anjos
Employee
Employee

Maybe

MAX(TOTAL <Date> AGGR( SUM (Value),Code,Date) )

Anonymous
Not applicable
Author

That is closer, but still not quite right.

It applies the max value between NP and PJ to the NP and PJ codes, but it does not apply the max value of RFN.

JonnyPoole
Employee
Employee

interesting.  i got different results when i typed in your data.

You may have hidden (but important) details in your app that you may need to share...

Capture.PNG

awhitfield
Partner - Champion
Partner - Champion

HI MIchael,

this may seem a daft question, but why do you want to do this, what are you trying to achieve eventually?

Andy