Creating a calculated field with LOD expression

0 votes

What I have?

purchase_log table with the following fields:

  • uid,
  • date,
  • category,
  • amount

What I want?

Visualize the first and second purchases dates for each user from every category.

For example:

+-----+------+----------+--------+ 
| uid | date | category | amount |
+-----+------+----------+--------+
| A   | d1   | c1       | 100    |
| A   | d2   | c2       | 200    |
| A   | d3   | c1       | 120    |
| A   | d4   | c2       | 300    |
+-----+------+----------+--------+

Considering the above sample data just assume that the first purchase is from category c1 and is made on date d1, and second purchase from category c1 is made on date d3.

I have created 3 calculated fields:

  • 1st purchase:

    { FIXED [uid] : MIN([date])}
    
  • Repeat purchase:

    IIF([date]>[1st Purchase],[date],null)
    
  • 2nd purchase:

    { FIXED [uid] : MIN([Repeat Purchase])}
    

But as there is no distinction between categories, I'm not able to see dates corresponding to categories.

How should I solve this problem?

Apr 17, 2018 in Tableau by xyz
• 1,550 points
58 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Go ahead and try the following three LOD's on both the uid and the category:

  • 1st purchase:

    { FIXED [uid],[category] : MIN([date])}
    
  • Repeat purchase:

    { FIXED [uid],[category]: IIF([date]>[1st Purchase],[date],null)}
    
  • 2nd purchase:

    { FIXED [uid],[category] : MIN([Repeat Purchase])}
answered Apr 20, 2018 by Atul
• 5,470 points

Related Questions In Tableau

0 votes
0 answers

Creating a multiple charts with calculated field

Sample data: Table Name: A Mode Country Month Visitor ...READ MORE

Aug 16, 2018 in Tableau by Atul
• 5,470 points
31 views
0 votes
1 answer

How to perform a calculation using one variable with an aggregation in calculated field?

Hi, You can use the calculative field and ...READ MORE

answered 6 days ago in Tableau by anonymous
• 13,940 points
12 views
0 votes
1 answer

Creating a dual axis chart with same measure in Tableau

Yes, this is possible. Drop the measure in ...READ MORE

answered May 28, 2018 in Tableau by Atul
• 10,200 points
598 views
0 votes
1 answer

Tableau charts with calculated field

I could get Visitor Rate = COUNTD(Visitor ...READ MORE

answered Jul 18, 2018 in Tableau by Atul
• 10,200 points
24 views
0 votes
1 answer

Calculated filed with if-then

Below is the required code:  IF (NOT ISNULL([test2])) ...READ MORE

answered Mar 27, 2018 in Tableau by Atul
• 10,200 points
36 views
0 votes
1 answer

How to calculate profit when cost and revenue are in same column?

You can create the following calculated fields: Profit: SUM(IIF([account_category] ...READ MORE

answered Apr 10, 2018 in Tableau by Atul
• 5,470 points
46 views
0 votes
1 answer

Calculation issue: Distinct sum in Tableau

SUM( { FIXED [Brand], [Market]: AVG(Target) } ...READ MORE

answered May 8, 2018 in Tableau by Atul
• 10,200 points
1,571 views
0 votes
6 answers

How to use COUNTIF in Tableau?

I'll give you a brief idea on ...READ MORE

answered Dec 10, 2018 in Tableau by Haider
4,697 views
0 votes
1 answer

Creating a calculated field for summing up the values

Well you can use this in your ...READ MORE

answered May 17, 2018 in Tableau by Atul
• 5,470 points
28 views
0 votes
1 answer

How to create a single calculated field from multiple column filtering?

Try with this calculated field: ( ...READ MORE

answered Jul 6, 2018 in Tableau by Atul
• 5,470 points
25 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.