Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
edwin
Master II
Master II

adding an aggregation bar in a chart

we recently had a requirement to show the aggregation of all results as a bar in a chart. for example if we have weekly values, we plot the sum of the values per week (week will be the dimension). then average the resulting sum and display as the first bar. 

 

Capture.PNG

we implemented this using a bridge in the script.  

does anyone know how this can be done without any additional tables in the DM?  just a regular expression in the chart?

Labels (3)
1 Solution

Accepted Solutions
Frank_Hartmann
Master II
Master II

You can also use Dimensionality()

see attached qvw. hope this helps

View solution in original post

12 Replies
Frank_Hartmann
Master II
Master II

Island Table with pick(dim,...) should work!

see attached. hope this helps

QFabian
Specialist III
Specialist III

Hi @edwin , you can try this example, that just add a line reference with the average you are looking for.

 

QFabian_0-1610032967187.png

 

 

 

QFabian
edwin
Master II
Master II
Author

@Frank_Hartmann we do have a few variations where we add new tables to simulate the extra dimension value (Average).  but thanks for the suggestion.  what i am looking for is a possible solution without adding a new table.


edwin
Master II
Master II
Author

@QFabian thanks for the suggestion but that isnt the visual the users specified.  yes we can probably convince the user to use that instead but we looked at this as a challenge which we were able to create but i was looking for a simpler solution.

edwin
Master II
Master II
Author

i was thinking in line of a ValueList combined with the possible weeks, but value list accepts only constants.  any ideas?

QFabian
Specialist III
Specialist III

Hi @edwin , please try this :

Script :

///your original data

LOAD * INLINE [
Week, Amount
11-10-2020, 1100
18-10-2020, 1400
25-10-2020, 850
1-11-2020, 1300
];

///new record

concatenate
LOAD * INLINE [
Week, Amount
Average, 0
];

expression : if(Week= 'Average',avg({<Week -= {'Average'} >}total Amount), Sum (Amount))

background color : if(Week= 'Average',lightred())

 

result :

QFabian_0-1610035987144.png

 

QFabian
edwin
Master II
Master II
Author

@QFabian thanks, we do have a few versions similar to what you have done.  we are looking for a frontend solution and hoping it might be better.

Frank_Hartmann
Master II
Master II

You can also use Dimensionality()

see attached qvw. hope this helps

edwin
Master II
Master II
Author

@Frank_Hartmann  That was very interesting.  thanks Frank.  can you pls explain how using dimensionality introduced a new column (or dimension entry)?  also, it looks like you cant sort it so that the aggr is the first bar - but that should not be a deal breaker