Qlikview Expression to get Average in comparison to selected criteria for Chart

StackOverflow https://stackoverflow.com/questions/18474202

  •  26-06-2022
  •  | 
  •  

Domanda

I am trying to create a chart that displays the average of a parameter of an entire category. The problem is that in sheet 1,2,3,4, etc, the charts I have reflect one parameter, so when I go to compare this parameter to the average in my new sheet, I only get the average of the fields that have been selected in prior sheets. I want it so that I can create a new chart with one bar as an average of the entire population, and another bar in the same chart that depicts the average of the selected parameter(s). Ideally, I would have two dimensions/x axis categories, one for the selected criteria, and one for average of all categories. Can someone help?

Thanks.

È stato utile?

Soluzione

I believe the way to handle this is with set analysis. You can create one expression with the normal avg(parameter) and another expression with some embedded set analysis. See example below.

Expression1: avg(parameter) // will agregate everything in the current selection

Expression2: avg({1<category='YourCategory'>}parameter) // will aggregate everything in a category that you set in the set analysis syntax.

With some more specific info I would be able to get you an actual expression, but hopefully this helps.

EDIT

Updated to reflect new information provided in the comments.

Expression1: avg(parameter)
Expression2: avg({1}parameter)

In set analysis syntax the {1} means the entire universe of data where as {$} is your current selection. In other words, 1 is your data with nothing selected. In my first example above, the {1<category='YourCategory'>} statement uses a modifier signified by the <> so that you would be performing the aggregation over the entire universe with only the value specified in YourCategory selected.

So if the scenario is that you have currently selected let's say, 5 zip codes, your current selection ({$}) would be those 5 zip codes and the entire universe ({1}) will be as if you selected no zip codes. Therefore comparing those two populations side-by-side in two Expressions should give you the comparison you want.

Caveat: Using the {1} syntax in your expression means that your average of "all zip codes" will always be the average with nothing selected unless you put something in the modifier as in my first example. See this more detailed explanation.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top