This week we have another collaboration and this time it's with our old friends at #WorkoutWednesday. For this collaboration we are looking to connect to Salesforce data and look to analyse some opportunity data.
Step 1 - Opportunity Table
The first step this week is to input the Opportunity table and then reshape it so that we have a row for when each Opportunity was Opened and a row for the Expected Close Data.
We can use a Columns to Rows pivot for this, where we pivot on the CloseDate & CreatedDate fields:
After the pivot we can rename the auto generated pivot fields:
Pivot1 Values to Date
Pivot1 Names to Stage
Then within the Stage field, we can rename the values:
CreatedDate to Opened
CloseDate to ExpectedCloseDate
We also need to rename a couple of the other fields within the Stage field:
Stage
IF [Stage]='ExpectedCloseDate' AND CONTAINS([StageName],'Close')
THEN [StageName]
ELSE [Stage]
END
Then finally we can remove a lot of the fields that we don't need to work with. From the table we want to Keep Only the Date, Stage, & ID fields.
Step 2 - Opportunity History Table
We can now turn to combining the Opportunity History table as well. As this is in a similar structure as the Opportunity table, we can 'stack' these on top of each other using the Union tool. At this stage we can remove the Table Names & SortOrder fields (we will bring the SortOrder back in later) so our table looks like this:
To bring the SortOrder back in so that each row one associated with it, we can use the Opportunity History table as a lookup. First we need to use an aggregation tool to Group the Stage Name & SortOrder fields so that we have a row for each combination:
Then we can join this lookup table to our existing workflow to associate each row with the SortOrder. To combine the tables we need to use a Left (or Right depending on your setup) join to ensure that we are retaining all of the rows from the existing workflow. We want to join where Stage = StageName:
Finally update a couple of the SortOrder values to correctly match the requirements using this calculation:
SortOrder
IF [Stage]='Opened'
THEN 0
ELSEIF [Stage]='ExpectedCloseDate'
THEN 11
ELSE [SortOrder]
END
The final step is to remove any values that have been duplicated when bringing the tables together. We can use an aggregation tool to Group all of our fields so we are left with a single row for each combination:
After the aggregation we are ready to output our data:
Once you have completed the challenge head over to the Workout Wednesday challenges (Tableau or PowerBI) so that you can use this data set to create & visualise your Salesforce Opportunities Dashboard!
You can also post your solution on the Tableau Forum where we have a Preppin' Data community page. Post your solutions and ask questions if you need any help!
Created by: Carl Allchin Welcome to a New Year of Preppin' Data. These are weekly exercises to help you learn and develop data preparation skills. We publish the challenges on a Wednesday and share a solution the following Tuesday. You can take the challenges whenever you want and we love to see your solutions. With data preparation, there is never just one way to complete the tasks so sharing your solutions will help others learn too. Share on Twitter, LinkedIn, the Tableau Forums or wherever you want to too. Tag Jenny Martin, Tom Prowse or myself or just use the #PreppinData to share your solutions. The challenges are designed for learning Tableau Prep but we have a broad community who complete the challenges in R, Python, SQL, DBT, EasyMorph and many other tools. We love seeing people learn new tools so feel free to use whatever tools you want to complete the challenges. A New Year means we start afresh so January's challenges will be focused on beginners. We will use dif
Challenge By: Jenny Martin For week 2 of our beginner month, Data Source Bank has a requirement to construct International Bank Account Numbers (IBANs), even for Transactions taking place in the UK. We have all the information in separate fields, we just need to put it altogether in the following order: Inputs A list of the transactions, with information about the receiving bank account A lookup table for the SWIFT Bank Codes Requirements Input the data In the Transactions table, there is a Sort Code field which contains dashes. We need to remove these so just have a 6 digit string ( hint ) Use the SWIFT Bank Code lookup table to bring in additional information about the SWIFT code and Check Digits of the receiving bank account ( hint ) Add a field for the Country Code ( hint ) Hint: all these transactions take place in the UK so the Country Code should be GB Create the IBAN as above ( hint ) Hint: watch out for trying to combine sting fields with numeric fields - check data types Re
Free isn't always a good thing. In data, Free text is the example to state when proving that statements correct. However, lots of benefit can be gained from understanding data that has been entered in Free Text fields. What do we mean by Free Text? Free Text is the string based data that comes from allowing people to type answers in to systems and forms. The resulting data is normally stored within one column, with one answer per cell. As Free Text means the answer could be anything, this is what you get - absolutely anything. From expletives to slang, the words you will find in the data may be a challenge to interpret but the text is the closest way to collect the voice of your customer / employee. The Free Text field is likely to contain long, rambling sentences that can simply be analysed. If you count these fields, you are likely to have one of each entry each. Therefore, simply counting the entries will not provide anything meaningful to your analysis. The value is in