Way to pivot multiple rows into columns in Tableau using Custom SQL? - pivot

I am using a snowflake data source for tableau and unfortunately the generated results show like this
Agent
Manager
Row
Question
Answer
Bob
Cindy
1
Breakfast?
yes
Bob
Cindy
2
Lunch?
no
Bob
Cindy
3
Dinner?
maybe
Jim
Debby
1
Breakfast?
yes
Jim
Debby
2
Lunch?
no
Jim
Debby
3
Dinner?
maybe
and I'm trying to get it to look like this
Agent
Manager
Question1
question2
question3
answer1
answer2
answer3
Bob
Cindy
Breakfast?
Lunch?
Dinner?
yes
no
maybe
Jim
Debby
Breakfast?
Lunch?
Dinner?
yes
no
maybe
The pivot options aren't available because it's coming from snowflake, and I only seem to find results that show how to convert columns to rows using SQL, but nothing showing how to do rows to columns in Tableau from a snowflake connection. There seems to be certain things you can't use in the tableau sql that you can do in snowflake so I'm just at a loss at this point.
The snowflake data is also unavailable to do queries on so I'm stuck only able to fix it through Tableau. Any suggestions on how to do this? or if it's doable? Thanks in advance.

Related

How do I create a filter to select a single term from a string in Tableau? I need to be able to select multiple terms

for example my data looks something like this:
Name
Age
Dessert
maria
12
cake; ice cream; cookies; candy
hannah
20
cake; candy
brian
8
ice cream; cookies
liam
13
candy
julie
32
cake; cookies
I want to create a filter like this that allows MULTI-SELECT:
Dessert
[]cake
[]ice cream
[]cookies
[]candy
A parameter did not work for me since it doesn't allow multi-select.
Please help!! Thanks so much!
edit: not sure if it matters but i have the data set up in an excel sheet if an edit there could help! but i need all the terms in a single filter! thanks!
i found that the best way to do this was to pivot the columns into rows in either tableau prep or using python. thank you for your help!

Excel Combine Rows with Partially Filled Columns

Would anyone be able to assist me with the following table?
Name
Apple
Pear
Banana
Bob
Yes
Bob
Yes
Alice
Yes
Alice
Yes
John
The goal is to have the all these rows merge/join and fill in all empty columns if the unique name is present. See below for the end goal.
Name
Apple
Pear
Banana
Bob
Yes
Yes
Alice
Yes
Yes
John
Please note that I am restricted in terms of using only Excel (2016) with no ability to add add-ons.
Much appreciated!
You can do it manually easily in 3 steps:
Replace all "Yes" values with number 1
Inside "Data" tab, Consolidate data
Replace all number 1 with "Yes"
Take a look at the video:
And probably you can record a macro with this for sure and make it instantly.

Excel - Sum/Count of boolean values

In Excel I am creating a simple scorecard for my Football Pool. Each week a player makes a prediction and the correct guess is in the bottom row.
This is a simplified version of it
Name
Week1
Week2
Week3
Total
Lee
BUF
LAR
TB
3
Beth
BUF
SEA
TB
2
Rick
TEN
LAR
TB
2
Fred
TEN
LAR
PIT
1
Winner
BUF
LAR
TB
My question is about keeping score. To compute the total in Column F I am currently adding the booleans manually:
=(B2=B$7)+(C2=C$7)+(D2=D$7)
This is fine for only three columns of course, but it will definitely get quite cumbersome if there are dozens (or more) columns.
I am wondering if there is a simpler way to accomplish this with a formula such as SUM() or SUMIFS() or COUNTIFS() etc.
Any help would be greatly appreciated. Thanks! :)
Use SUMPRODUCT:
=SUMPRODUCT(--(B2:D2=$B$7:$D$7))

Excel Graphs - Exclude someone who is off

I have data, in two separate columns, that shows people and how many products they have sold in the previous day:
Alan 12
Gareth 7
Kristina 8
Fred Off
Emma 7
What I would like to do is not include Fred in the graph as he was off for that day. Is there an easy way to exclude someone if they were "off"?
Any ideas are appreciated :)
Just Add a filter in those columns. Now filter the column to remove the value Off. The graph will be updated automatically.

Sum of values in column for each value in adjacent column

I have some data on number of pages printed which is basically a row for each print job with username and number of pages. I want a total of pages for each user.
my data looks like this:
COL1 COL2
dave 2
john 3
dave 1
sally 5
sally 1
john 2
dave 4
ben 8
and I want to end up with:
COL1 COL2
dave 7
john 5
sally 6
ben 8
=SUMIF(COL1:COL1,"dave",COL2:COL2)
Note that doing it this way will require you to enter each name individually when counting. Watch out for circular reference.
Use Pivot tables. It's exactly made for analysis as you describe. Pivot tables is a builtin feature in Excel and a quite powerful analysis tool.
Start with selecting your data to be analyzed and then make a pivot table out of that data.

Resources