What I want?

Get all Customers from a certain city that made an order from the same city on a certain date range and made the order from the same city at any Date before this certain Date range.

What I did?

I tried was to Create 3 Parameters, one that holds the Certain Order_Date called "Certain_Date", one that Hold the End Date of a Date Range I want to see called "End_Date" and one that holds the Name of the city "Certain_City".

Here my Calculation field:

```IF { FIXED [Customerid], [Certain_City] : MIN(Order_Date) < [Certain_Date] }
AND { FIXED [Customerid], [Certain_City] : MAX(Order_Date) >= [Certain_Date]}
THEN "Customer Ordered from City before"
ELSE "Customers first Order from this City"
END
```

This Calculated field, however, does not work, it only gets me the Customers that made an order from any City before.

Also, I used a Filter to show only the CustomerID-s that ordered from the Certain_Date to the End_Date. But it won't work, any Ideas?

Here An Example of what I want:

```>     Order_Date Customer_ID City
>     01.10.2016 1234        Stockhom
>     01.05.2016 1234        Stockhom
>     01.03.2016 1234        Oslo
>     05.10.2016 1455        Berlin
>     01.04.2016 1455        Berlin
>     02.10.2016 1211        Stockhom
>     06.03.2016 1211        Prague
```

Let say the "Certain_Date" is 01.10.2016 and the "End_Date" is 03.10.2016

From this Data I want to create a Barchart that holds the Number of Unique CustomerID-s, and that colors the "Customer Ordered from City before" and the "Customers first Order from this City".

In this Example the Barchart would go up to 3 Elemnts. Where the CostumerID-s 1234 and 1455 would be colored Blue because they ordered from the same City before, and 1211 would be colored Red because it ordered before the Date but not from the same City.

Aug 30, 2018 in Tableau 603 views

## 1 answer to this question.

Try This

Create 3 parameter

1. Start Date

2. End Date

3. City

Now

Create a Calculated Field C1

``` {fixed [Customer],[OrderCity]:max(if OrderDate>=StartDate and OrderDate<=EndDate then 1 end)}
```

Create Another Calculated Field C2

``` If C1>=1 and orderDate<StartDate then 'true' else 'False' end
```

Put This C2 in Filter Set Default value=True

Tell me if it worked?

answered Aug 30, 2018 by
• 10,240 points

## Filtering multiple combinations of two fields in single worksheet

Hi anitha, Follow below steps: 1. Split the order ...READ MORE

## Aggregating multiple column in Tableau

You can use Tableau’s inbuilt pivot method ...READ MORE

## How to aggregate multiple column in Tableau?

You can use Tableau’s inbuilt pivot method ...READ MORE

+1 vote

## How to perform top N fields with nested sort in tableau

You can use the following steps: Sort 'State' ...READ MORE

## How to create a filter based on date range?

You can use this code snippet in ...READ MORE

## How to display days data based on date selected in the filter by the user.

You can create a parameter for dates. Select data ...READ MORE

## Action filter (on set) is appearing in my worksheet.

Those are the action filters that we ...READ MORE

+1 vote

## How to join tables based on “Calculated Fields” in Tableau?

You absolutely can join to a calculated ...READ MORE