Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
jelindbe
Partner - Contributor III
Partner - Contributor III

Combining measurements

I have two kinds of measurements. One measurement is used for static information. This measure shows last observed year if the user does not select year - typically in a kpi (see measurement 1). The other measurement is used to show information through years - typically in a line chart (see measurement 2). The measurements are like this:

1)

if(GetSelectedCount(Year)=0,

Sum({<Year={$(=MAX({$<Sales -= {'=(NULL())'} >}Year))}>}Sales),

Sum(Sales))

2)

Sum(Sales)

As they are constructed I cannot use measurement 1 in a line graph for example. I would like to combine measurement 1 and 2 into a single measurement so that they will display information regardless of chart type. The main reason - it will not be easy to maintain when I have several 'dualistic' measurements of the same kind.

8 Replies
sunny_talwar
MVP
MVP

Why can't you use this in a line chart? I think you should be able to use this... unless I am missing something?

If(GetSelectedCount(Year) = 0,

Sum({<Year = {$(=Max({$<Sales = {"*"}>} Year))}>} Sales),

Sum(Sales))

jelindbe
Partner - Contributor III
Partner - Contributor III
Author

I have prepared an example. In the first line graph I use measurement 2) for both lines. In the second graph I have substituted the red line with measurement 1). As you see the result is a dot (giving the result for MAX year). It will be like this (GetSelectedCount(Year) = 0) unless I actively chooses several years from the filter pane.

example.png

sunny_talwar
MVP
MVP

So, what exactly do you wish to see happen in your second chart?

jelindbe
Partner - Contributor III
Partner - Contributor III
Author

When a user has not selected any years, I wish the second chart to display exactly like the first chart.

sunny_talwar
MVP
MVP

And what will you see when something is selected by the user?

jelindbe
Partner - Contributor III
Partner - Contributor III
Author

When the user has selected one or several years, I want the line chart to display the years accordingly.

sunny_talwar
MVP
MVP

Then why can't you just use Sum(Sales)? That seems to be exactly what you are looking for... what do you need measurement for?

jelindbe
Partner - Contributor III
Partner - Contributor III
Author

I CAN use Sum(Sales), but the problem is to maintain double sets of expressions. I have the same duplicate issue for several measures. That is duplicates of names (with slightly differences), expressions (with slightly differences), label expressions (with slightly differences 🙂 and descriptions (which will be the same, but needs to be updated two places when necessary). I hoped there could be a more rational possible solution.