7 Replies Latest reply on Aug 4, 2016 11:50 AM by Gilberto Diaz

# Return all rows based on if conditions!!

Greetings to the Tableau community;

I would like to return all customer's visit based on one condition, however, it is returning the rows with just that condition. Let me explain in more detail. Let say that I have this table

Name | Date | Amount | Payment_Method

And let say that all customers have come to my store more than once, therefore, I have more than one visit per customer. Lets pretend that I have 4 payment methods and I want all the records of those customers that had pay with payment method 3 at least once. I want all the visits of those customers. So the query should return something like this:

customer 1 | visit 1 | \$1.00 | 1

customer 1 | visit 2 | \$3.00 | 3

customer 1 | visit 3 | \$2.00 | 2

This is my code:

IF[payment_method] = 3

THEN [customer_id]

ELSE ""

END

This code is returning just the records with payment method 3.

Make sense what I want?

• ###### 1. Re: Return all rows based on if conditions!!

Try this: { fixed [Name] : max(if [Pament Method] = 3 then [Name] end )}

3 of 3 people found this helpful
• ###### 2. Re: Return all rows based on if conditions!!

Just checking:

You want all lines for clients who payed with [payment_method] = 3 at least once?

• ###### 3. Re: Return all rows based on if conditions!!

I'm working with the code. I'll get back to you shortly.

• ###### 4. Re: Return all rows based on if conditions!!

Yes!

• ###### 5. Re: Return all rows based on if conditions!!

Pooja Gandhi

I did a "Create a Calculated field" with your code and throw that into filters and is not working.

Something I'm doing wrong????

• ###### 6. Re: Return all rows based on if conditions!!

Hard to say what isn't working without looking at your workbook. Can you attach the workbook?

• ###### 7. Re: Return all rows based on if conditions!!

Pooja Gandhi

Ok, When I add the filter, two variables combine into one and I can't figure out how to separate them.

Customer ID and Year got combine into one variable.

Why is doing that?