Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
samuel_brierley
Creator
Creator

Quick set analysis question

Hi all,


below is a formula im using to average the NOx as you can see but im having an issue witht eh set analysis, where I say {$(=num(avg([Speed(Lane 1)]),'#.')), its calculating the average of the whole selected range and not by the dimension, e.g


TimeSpeed (Lane 1)$<[Average speed (km/h)] = {$(=num(avg([Speed(Lane 1)]),'#.'))}>}What I Want

00:00

506550
00:01606560
00:02706570
00:03806580

60

avg({$<[Average speed (km/h)] = {$(=num(avg([Speed(Lane 1)]),'#.'))}>} [NOx EF (g/km)])

what I want the formula to do is avg the NOx where the Speed (Lane 1) = Average Speed (km/h) (I cant rename the fields unfortunately)

one possible answer is to add the Time dimension into the formula in the same way I have done with the Speed Field but I couldn't get that to work.

hopefully that is enough info to get you started, I imagine its quite a simple change.

thanks

8 Replies
Peter_Cammaert
Partner - Champion III
Partner - Champion III

Set analysis works before the chart is recalculated. You cannot use it to perform row-by-row evaluations/calculations.

aggr() will be your friend.

Peter

Clever_Anjos
Employee
Employee

Set Analysis filters are made before calculation of each row.

It´s the way it works by design

hic
Former Employee
Former Employee

No, it's not a just a simple change. The dollar expansion and the Set Analysis selection is made before the chart is calculated.

Set Analysis is never evaluated for each row. You can only use expressions that can result in selections before the chart is evaluated.

Further, I am not quite sure I understand what you want to achieve... In the first row of your chart, the "Speed (Lane 1)" is 50. But then you also a field "Average speed (km/h)". How does this relate to the first field? And how could it ever be different from 50 on the first row?

HIC

samuel_brierley
Creator
Creator
Author

What im trying to achieve is simply avg the NOx where the [Average speed (km/h)] is equal to the speed In lane 1

avg({$<[Average speed (km/h)] = {$(=num(avg([Speed(Lane 1)]),'#.'))}>} [NOx EF (g/km)])

Peter_Cammaert
Partner - Champion III
Partner - Champion III

Can you please post a file with example source data? That would make it a lot easier to find a solution. Thanks.

Peter

samuel_brierley
Creator
Creator
Author

Cheers Peter for looking at this,

hic
Former Employee
Former Employee

I understand that you want to calculate the avg NOx using some condition, but I don't understand how [Speed (Lane 1)] relates to [Average speed (km/h)]. Especially since you use [Speed (Lane 1)] as dimension in your chart.

Anyway, posting some data, as Peter suggests, is probably a good idea.

HIC

samuel_brierley
Creator
Creator
Author

there are two tables, one contains vehicle information inc speed(lane 1,2,3) and vehicle type. the other table contains vehicle type, speed and NOx (the field I want to return).

the 2 tables are linked by the vehicle type so I should be able to return the NOx for each vehicle type at the speed recorded in the first table.

that was my assumption anyway but its proving more difficult than that.