4 Replies Latest reply on Dec 5, 2016 2:35 AM by Sean Murphy

# Count of Orders by Total Duration

Hello!

I'm currently trying to figure out how to get the number of orders that fall within each total duration.

The data I have is like this:

Each order has 3 stages. Those stages durations together equal the total order duration.

I am calculating this with: window_sum(sum([duration]))

I put Order ID on the detail to allow the table calculation to give the proper total durations.

Now I have that table calculation as the first column in this picture:

The second column is COUNTD(Order ID). It's returning 1 for each row, what I want to get is 2 for the second row because there are 2 deliveries that have 20 as the total duration.

Can anyone help? I've attached the workbook.

• ###### 1. Re: Count of Orders by Total Duration

hi Sean,

So I assume here the Step is in the Viz, so you can calculate the total sum (using your Window_Sum).

Much easier is to use a FIXED LoD...these are calculations which let you prescribe the level at which they are run, then returns this to every row of the data (at that level). As such we can use it as a real dimension...once we have this we can just do a COUNTD on Oder ID.

Hope that makes sense, but if not please post back and I'll point you at some good LoD Calc resources.

1 of 1 people found this helpful
• ###### 2. Re: Count of Orders by Total Duration

Was just writing this as Simon posted so will post anyway...

LOD is the way to do this, assuming you're using Tableau 9+.

Create the calculated field to set the total duration per order:

{ FIXED [Order Id]:SUM([Duration])}

Drag that to the dimensions then you can use as Simon suggested.

1 of 1 people found this helpful
• ###### 3. Re: Count of Orders by Total Duration

...Let's go with "Great minds think alike"