4 Replies Latest reply on Jul 3, 2018 4:35 AM by Zhouyi Zhang

    How to calculate the first value by category?

    Simin Xu

      Hello! I have a specific question regarding customer retention rate by category (see attached): How do I create a calculated field which filled by the first total number of people by city and by pay type in tableau? How to define the function?

      For example, I have 5 columns:


      • first_week is the first week that people purchased our products.
      • week_no is the week number that people purchased our products again.
      • total_num is the total number of people that have purchased our products.
      • pay_type is the type of payment (cash, or credit)
      • city is the city that people finished order
      In order to calculate the retention rate, I need to create a new field which is the number of people who bought our products by city and pay type for the first time. In the following, cal1 is the new field, and retention_rate is the total_num divided by cal1. I just wondering if there is a function to calculate cal1 in order to get the retention rate?


      I really appreciate anyone can help!


      current dataset is like this: