Set difference find distinct members for two groups in Tableau Desktop

0 votes

In Tableau Desktop, how do I accomplish the following set difference/group differentiation task?

I have items that have been adjusted or have not been modified (adjusted = 1 or adjusted = 0). Please keep in mind that any product may appear more than once (as the real dataset is a a matrix of stacked time series for each product).

I'm curious as to how many products had at least one adjustment and how many did not.

In R, I'd do it like this:

Data example:

dat <- data.frame(
  product = c("4005808588763", "4005808250004", "4005808157822",
    "4005800031052", "4005808855735", "4005808651818", "4005808322053",
    "4005808236879", "4005800091629", "4005808361434", "42277248",
    "4005808224074", "9005800249858", "42277835", "4005808627356",
    "8005800010985", "4005808323197", "4005808186129", "4005800059254",
    "4005808818587", "4005900175410", "72140018627", "4005800059292",
    "72140008499", "4005808125968", "42269847", "4005808675173",
    "72140016371", "4005808765157", "4005900123763", "4005808816019",
    "4005800062575", "4005808293872", "4005900143952", "8850029006536",
    "4005800136986", "42231493", "4005808715688", "4005800053085",
    "4005800059629", "4005808847419", "4005800031656", "4005900273994",
    "4005900261038", "6009661219022", "42240181", "8850029016030",
    "4005900146274", "42176152", "4005808158096"), 
  adjusted = c(1L, 1L, 0L, 1L, 0L, 1L, 1L, 0L, 1L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 0L,
      1L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 1L,
      0L, 1L, 1L, 1L, 1L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L,
      1L)
  )
#          product adjusted
# 1  4005808588763        1
# 2  4005808250004        1
# 3  4005808157822        0
# 4  4005800031052        1
# 5  4005808855735        0
# 6  4005808651818        1
# 7  4005808322053        1
# 8  4005808236879        0
# 9  4005800091629        1
# 10 4005808361434        0
# 11      42277248        1
# 12 4005808224074        1
# 13 9005800249858        0
# 14      42277835        0
# 15 4005808627356        0
# 16 8005800010985        0
# 17 4005808323197        0
# 18 4005808186129        1
# 19 4005800059254        0
# 20 4005808818587        0
# 21 4005900175410        1
# 22   72140018627        1
# 23 4005800059292        1
# 24   72140008499        1
# 25 4005808125968        1
# 26      42269847        0
# 27 4005808675173        1
# 28   72140016371        1
# 29 4005808765157        1
# 30 4005900123763        0
# 31 4005808816019        0
# 32 4005800062575        0
# 33 4005808293872        1
# 34 4005900143952        0
# 35 8850029006536        1
# 36 4005800136986        1
# 37      42231493        1
# 38 4005808715688        1
# 39 4005800053085        0
# 40 4005800059629        0
# 41 4005808847419        0
# 42 4005800031656        1
# 43 4005900273994        1
# 44 4005900261038        1
# 45 6009661219022        1
# 46      42240181        1
# 47 8850029016030        1
# 48 4005900146274        1
# 49      42176152        0
# 50 4005808158096        1

Split into two data frames:

g1 <- filter(dat, adjusted == 0)
g2 <- filter(dat, adjusted == 1)

Find unique product IDs:

(id_1 <- unique(g2$product))
# [1] "4005808588763" "4005808250004" "4005800031052" "4005808651818" "4005808322053"
# [6] "4005800091629" "42277248"      "4005808224074" "4005808186129" "4005900175410"
# [11] "72140018627"   "4005800059292" "72140008499"   "4005808125968" "4005808675173"
# [16] "72140016371"   "4005808765157" "4005808293872" "8850029006536" "4005800136986"
# [21] "42231493"      "4005808715688" "4005800031656" "4005900273994" "4005900261038"
# [26] "6009661219022" "42240181"      "8850029016030" "4005900146274" "4005808158096"

(id_2 <- setdiff(unique(g1$product), id_1))
# [1] "4005808157822" "4005808855735" "4005808236879" "4005808361434" "9005800249858"
# [6] "42277835"      "4005808627356" "8005800010985" "4005808323197" "4005800059254"
# [11] "4005808818587" "42269847"      "4005900123763" "4005808816019" "4005800062575"
# [16] "4005900143952" "4005800053085" "4005800059629" "4005808847419" "42176152"

I'm not sure how to go about developing such a query because I'm new to Tableau.

Apr 14, 2022 in Tableau by Neha
• 9,060 points
426 views

No answer to this question. Be the first to respond.

Your answer

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

Related Questions In Tableau

0 votes
1 answer

Combined set for dynamic selection of members in a set

Hi Priyanka Follow the below steps: 1. Create 2 ...READ MORE

answered Jun 12, 2019 in Tableau by anonymous
• 33,030 points
652 views
0 votes
1 answer

Urgently Require Data Set used in Tableau 6 Hours Training for Beginners

Hi, @Aneeqzafar, You can follow these datasets sheets ...READ MORE

answered Jun 4, 2020 in Tableau by Gitika
• 65,890 points
3,146 views
0 votes
1 answer

combine two data sets in tableau so that I can show a forecast for the next 3 months

I believe the best approach is to ...READ MORE

answered Apr 5, 2022 in Tableau by Vaani
• 7,070 points
847 views
0 votes
1 answer

Do I need a license for Tableau Server to publish content from Tableau Desktop to the Server?

According to this setup you do not ...READ MORE

answered Apr 17, 2018 in Tableau by xyz
• 1,560 points
1,034 views
0 votes
2 answers

Calculation issue: Distinct sum in Tableau

I feel the easiest way is to ...READ MORE

answered Aug 26, 2020 in Tableau by Dhiraj Kumar Sahu
9,527 views
0 votes
0 answers

Set difference: find distinct members for two groups in Tableau Desktop

In Tableau Desktop, how do I accomplish ...READ MORE

Apr 13, 2022 in Tableau by Neha
• 9,060 points
432 views
0 votes
1 answer

Is there a preferred file format for importing data into Tableau?

I don't have a final solution for ...READ MORE

answered Mar 29, 2022 in Tableau by Vaani
• 7,070 points
712 views
0 votes
1 answer

Big Data transformations with R

Dear Koushik, Hope you are doing great. You can ...READ MORE

answered Dec 18, 2017 in Data Analytics by Sudhir
• 1,610 points
980 views
0 votes
2 answers

Transforming a key/value string into distinct rows in R

We would start off by loading the ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,660 points
1,081 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