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

Set Analysis - Average of one field where another field is equal to monthly maximum

I have sensor data that takes readings of temperature at different depths every day. I want to have a table that lists the average temperature each month for only readings taken at the *maximum* depth for that month.

Example input data:

IDDateDepthTemperature
11/1/2009450
11/1/2009540
11/15/2009538
12/2/2009160
12/2/2009640

 

Desired output:

DateAvg Temp at Deepest
Jan-200939
Feb-200940

 

I've been trying every set expression I can think of, but it's not giving me the correct results.

I tried Avg({<Depth={"$(=Max(Depth))"}>}Temperature), but that just returned null for each month, *unless* I selected a specific month, and then it would give me the correct value (but just for that month).

I tried Avg({<ID=P({<Depth={"$(=Max(Depth))"}>})>} Temperature), but that gave me values that were just wrong.

I even tried some Avg(Aggr(Avg(... expressions, but couldn't get them to work either.

Any ideas?

Labels (1)
1 Reply
lironbaram
Partner - Master III
Partner - Master III

Hi

try this expression

 FirstSortedValue(aggr(avg(Temprature),Depth,Month),-aggr(Depth,Depth,Month))

where month is a field i created in the script by using this expression : monthstart(Date)