3 Replies Latest reply on Aug 25, 2018 1:43 AM by Dilyana Suleymanova

# Max per Segment/Superstore

hello there,

I have follow chart

Please ignore the double axis for now!

On the line chart, you see the sales per day per segment (where the segment is on the color)

I want to show a point in the line chart, which shows the max for each segment, e.i the point by the segment: Home Office in March 2015 with the sales of \$28,107. (So each segment should have only one dot! )

This is my calculated field for this idea:

max({ FIXED [Segment], DATETRUNC('day', [Order Date]): SUM([Sales])})

However, with this calculated field, I show all points (see the dot chart)

how can I fix this?

Thanks

DB

• ###### 1. Re: Max per Segment/Superstore

Great question, and you're definitely headed in the right direction. You have the right value calculated so far - the max value for each segment each day. The trick is to calculate this as the max for a segment for ALL days. To accomplish this, first find the max for each segment, then compare it to the max value for each segment in each day. If these equal, you've found the right day, and that's where you should draw the dot. If you do the below without everything to the right of the equals sign, you will get the right value, but drawn for every day.

IF SUM({FIXED [Segment] : MAX({ FIXED [Segment], DATETRUNC('day', [Order Date]): SUM([Sales])})})

= SUM([Sales]) THEN SUM([Sales]) END

• ###### 2. Re: Max per Segment/Superstore

Exactly what Ben said. You're basically just doing nested LOD calculations.

• ###### 3. Re: Max per Segment/Superstore

thank you so much!