Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
cordjohnr
Contributor
Contributor

Line chart with an average line trend

Hi - I'm looking to create a line chart with the x-axis Date and the y-axis Dollars. There should be three lines, one for Joe Doe, one for Jane Doe, and an average. In addition, how do I create the average line that ignores Name selections?

Is there an easier way if the table was built differently? Looking for suggestions.

Thanks!

**Edit for clarity**

The following is a sample data set and will include more names than just the two.

LOAD * INLINE [

Date, Dollars, Name
38565, 812, Joe Doe
38596, 928, Joe Doe
38626, 592, Joe Doe
38657, 418, Joe Doe
38687, 654, Joe Doe
38718, 1000, Joe Doe
38749, 255, Joe Doe
38777, 108, Joe Doe
38808, 484, Joe Doe
38838, 179, Joe Doe
38869, 645, Joe Doe
38899, 985, Joe Doe
38930, 328, Joe Doe
38565, 322, Jane Doe
38596, 668, Jane Doe
38626, 178, Jane Doe
38657, 404, Jane Doe
38687, 339, Jane Doe
38718, 716, Jane Doe
38749, 641, Jane Doe
38777, 495, Jane Doe
38808, 765, Jane Doe
38838, 519, Jane Doe
38869, 340, Jane Doe
38899, 356, Jane Doe
38930, 253, Jane Doe

];

Labels (2)
3 Replies
Lisa_P
Employee
Employee

Use Date as dimension and 3 measures:

Measure 1   Sum({<Name={'Joe Doe'}>}Dollars)
Measure 2   Sum({<Name={'Jane Doe'}>}Dollars)
Measure 3   Avg(Aggr(Sum(Dollars), Name, Date))

Capture.PNG

 

cordjohnr
Contributor
Contributor
Author

Thank you, Lisa. Though this gets me what I need for the sample data set, is there any way to not create separate measure expressions for additional names needed on the chart. In the end, I may have over 50 names that are changing over time, and I don't want to write a measure expression for each name.

Lisa_P
Employee
Employee

A standard line chart can have up to 2 dimensions with one measure, or 1 dimension and up to 15 measures, so here is another way to get around this by calculating the average in the data load script:

Table:
LOAD * INLINE [
Date, Dollars, Name
38565, 812, Joe Doe
38596, 928, Joe Doe
38626, 592, Joe Doe
38657, 418, Joe Doe
38687, 654, Joe Doe
38718, 1000, Joe Doe
38749, 255, Joe Doe
38777, 108, Joe Doe
38808, 484, Joe Doe
38838, 179, Joe Doe
38869, 645, Joe Doe
38899, 985, Joe Doe
38930, 328, Joe Doe
38565, 322, Jane Doe
38596, 668, Jane Doe
38626, 178, Jane Doe
38657, 404, Jane Doe
38687, 339, Jane Doe
38718, 716, Jane Doe
38749, 641, Jane Doe
38777, 495, Jane Doe
38808, 765, Jane Doe
38838, 519, Jane Doe
38869, 340, Jane Doe
38899, 356, Jane Doe
38930, 253, Jane Doe
];


Concatenate(Table)
Load Date,
'Avg' as Name,
Avg(Dollars) as Dollars
Resident Table Group By Date;

This will show as:

avg2.PNG