Skip to main content

Hello Tableau community,

 

I have just began using tableau a couple months ago and I have been trying this calculation for a bit but had no accurate results.

 

I have a dataset with the following variables:

 

[Transaction Date]

[Transaction ID]

[User}

[Category]

[store]

 

I need to find how many users had 2 or more transactions in the past year per store. And the users that had 2 or more transactions, of 2 or more different categories, all in the past year.

 

Note: If the same user goes to two different stores, it needs to be counted as two different users.

 

My best attempt is :

 

{fixed [User]: Countd(IF DATEDIFF('day', [Transaction Date], { FIXED : MAX([Transaction Date])}) <= 365 AND {fixed [User]: COUNT(User)} > 1

THEN [User]

END

)}

 

However, this did not give me accurate results as it counts users who made 1 transaction in the past year and but in multiple categories for a long time.

 

Does anyone know any better solutions?

 

Thanks for the help!

2 个回答
  1. 2022年8月18日 22:15

    @Rafa Braga​ 

    Hi, It woulbe easier if you could upload a workbook. I will give my best attempt:

     

    I need to find how many users had 2 or more transactions in the past year per store

    SUM({FIXED [User],[Store]:

    IF COUNTD(IF DATEDIFF('day', [Transaction Date], {MAX([Transaction Date])}) <= 365 THEN [Transaction ID] END)>1 THEN 1 ELSE 0 END

    })

    And the users that had 2 or more transactions, of 2 or more different categories, all in the past year.

    SUM({FIXED [User],[Store]:

    IF COUNTD(IF DATEDIFF('day', [Transaction Date], {MAX([Transaction Date])}) <= 365 THEN [Transaction ID] END)>1 AND COUNTD(IF DATEDIFF('day', [Transaction Date], {MAX([Transaction Date])}) <= 365 THEN [Category] END)>1

     THEN 1 ELSE 0 END

    })

    If this post resolves the question, would you be so kind to "Select as Best"?. This will help other users find the same answer/resolution and help community keep track of answered questions. Thank you.

     

    Regards,

     

    Diego Martinez

    Tableau Visionary and Forums Ambassador