Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
johnnyjohn
Creator
Creator

How to make calculated measure into dimension (for histogram)

Hi,

I would like to make a calculated measure into a dimension so that I can use it in a histogram. 

Note I can't compute the new value in the load script, it has be done dynamically. That's because the calculation is based on a variable that the user can change from the dashboard. 

I've tried doing the below as my dimension, but no success - "the chart is not displayed because it contains only undefined values" 

Aggr(Avg(price * vVarModifier), item_ID)

Any help would be much appreciated.

Labels (6)
6 Replies
hic
Former Employee
Former Employee

Your expression looks correct.

So you need to do some debug work to find the problem, e.g.:

  • Put the expression (with a leading equals sign) in a filter pane instead, to see which values the Aggr() returns.
  • Put the measure in a KPI object instead, to see which values it returns.
  • Check that the variable contains numeric values.
johnnyjohn
Creator
Creator
Author

I removed the variable, just to make sure it wasn't an issue with using a variable.

With no variables, the histogram returns the same. A KPI returns nothing ('-'), but  a filter returns my values correctly. So my expression does return correctly a list of integers, as I expect. Not sure where to go from here. Any ideas? 

EDIT: 

One interesting I have noticed is if I create a filter with Aggr(Sum(price *  qty),item_ID), the frequency count on the filter doesn't work, it shows all as '-'. But if I use in the filter (price * qty), the frequency count does work. Ultimately I need to perform the first calculation though. Not sure if that provides any hints as to what is going on.

hic
Former Employee
Former Employee

Are you using a histogram or a bar chart?  They are quite different... If you use a bar chart, then what do you use as a measure?

Aggr() can be used as a dimension, but if you use it as a measure, you should wrap it in an aggregation function, like Sum(Aggr(...)).

johnnyjohn
Creator
Creator
Author

I'm using a histogram.

I can sort of replicate what I'm trying to achieve on a bar graph, using CLASS and AGGR as a dimension and COUNT the ids as a measure. 

However, I can't use the barchart because the labeling doesn't scale like it does for the histogram object, and I need my histogram object to be small. Also, the barchart shows buckets created by the class function, not the raw number on the label (while histograms do show that number and the buckets adjust dynamically).

See images below to see why I need a histogram, not a barchart. On the left is a barchart, on the right a histogram. 

Histo.PNG

hic
Former Employee
Former Employee

Could be a bug. We'll look into it.

johnnyjohn
Creator
Creator
Author

Hello! Just curious if you had a chance to look at this - or understand what is going wrong here? 

Thanks