Tableau - Conditions on LOD Expression

0 votes

The fields in the purchase log table are as follows:

uid, date, category, and amount are all unique identifiers.

I'd also want to know the dates of each user's first and second purchases in each category.

Consider the following scenario:

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

For the following user data, I'd want to state that the first purchase from category c1 occurred on day d1, and the second transaction occurred on date d3.

I've developed three computed fields so far:

  • 1st purchase:

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

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

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

However, because there is no differentiation between categories, I am unable to view dates in relation to them.

How do I approach this issue?

Thanks.

Mar 14, 2022 in Tableau by Neha
• 9,060 points
1,773 views

1 answer to this question.

0 votes

You can use LODing on both uid and the category.
Refer the following commands for reference.

  • 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])}

Elevate your data visualization skills with our Tableau Course and unleash the power of insightful analytics.

answered Mar 16, 2022 by Vaani
• 7,020 points

Related Questions In Tableau

0 votes
0 answers

Tableau - Bins based on Fixed LOD Customer Units

What I'm attempting to do is create ...READ MORE

Mar 25, 2022 in Tableau by Neha
• 9,060 points
343 views
0 votes
1 answer

How to color code cells of a column based on the text value in Tableau

You can use the following steps to ...READ MORE

answered Mar 27, 2018 in Tableau by Atul
• 10,240 points
9,420 views
0 votes
1 answer

How to use LOD to count distinct number of records based on some condition?

From the desired output it seems that ...READ MORE

answered Apr 9, 2018 in Tableau by xyz
• 1,560 points
17,007 views
0 votes
1 answer
0 votes
0 answers

Using Python and Tableau in conjunction with one another

Is it possible to mix Python visualisations ...READ MORE

Feb 28, 2022 in Tableau by Vaani
• 7,020 points
329 views
0 votes
0 answers

Tableau Desktop Inside Tableau Server

Is there an executable for Tableau Desktop ...READ MORE

Feb 28, 2022 in Tableau by Vaani
• 7,020 points
343 views
0 votes
0 answers

Tableau Map view Continent List

I've been attempting to tidy up my ...READ MORE

Feb 28, 2022 in Tableau by Vaani
• 7,020 points
416 views
0 votes
0 answers

Downloading tableau workbook from tableau server with data

I'm brand new to tableau server. I ...READ MORE

Feb 28, 2022 in Tableau by Vaani
• 7,020 points
409 views
0 votes
1 answer

Tableau - What would the LOD calculation be?

Based on your requirements, I don't feel ...READ MORE

answered Mar 3, 2022 in Tableau by Vaani
• 7,020 points
433 views
0 votes
1 answer

How to create a responsive layout on Tableau dashboards?

You can position components in a vertical ...READ MORE

answered Mar 30, 2022 in Tableau by Vaani
• 7,020 points
598 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP