Welcome back to Workout Wednesday!
This week we’re going to visualize Twitter data using Twitter’s API to retrieve tweets that have been made about Workout Wednesday! You have complete creative license to visualize the data in any way that you see fit.
If you have a Power BI premium license, I encourage you to try using text analytics in Power Query! Use the sentiment analysis to score the Tweets to start – it’s simple and fun.
- Get data from the Twitter API
- this requires signing up for a Twitter Developer Account, which is free and fairly straightforward
- once you have completed the sign-up you’ll receive an API key, an API secret, and a token. Keep these somewhere safe – you’ll need them to pull data.
- I used Chris Koester’s instructions and modified them slightly to reflect v2 of the API.
- The query I used can be pasted into the advanced editor of a blank query. Note that you’ll need to add your own API Key and API Secret.
- If you do not have/use Twitter, pull the data from an Excel spreadsheet
- Transform the data
- Keep only the columns you need
- Create a fact table containing Tweet data that contains:
- created time
- author id
- Create a dimension table for your users that contains:
- profile image URL
- follower count
- Create measures for Tweets, Retweets, and unique users
- Add a date of last refresh to your data model. You can do this in either Power Query or with DAX.
- Create your report
- I used the Hex Color Picker chrome extension to grab Hex codes from Twitter
- Create a visual that displays latest tweets about Workout Wednesday! Include who created the tweet and maybe even where they’re tweeting from!
- Ensure font sizes are > 12pt and color contrast ratio is at least 3:1
- Add a timestamp to show report consumers when data was last refreshed.
- Add any other visuals that speak to you as you explore this dataset! Make the design your own and have fun with it!
If you do not have a Twitter account but you’d still like to play around with the API, you can do so in the Twitter API playground. Refer to the documentation to see what you can do with the API – it’s pretty fun!
Note that there are a couple of limitations with what you can pull.
- data is limited to 100 tweets
- you can only pull data from the last week
- user info doesn’t require a location, so some profiles may not have a location and/or a profile pic
If you’re not interested in creating a developer account, you can access the data in Excel. Note that this data was last pulled on 23 November.
After you finish your workout, share on Twitter using the hashtags #WOW2022 and #PowerBI, and tag @JSBaucke, @MMarie, @shan_gsd, @KerryKolosko, and @NerdyWithData. Also make sure to fill out the Submission Tracker so that we can count you as a participant this week in order to track our participation throughout the year.