2023: Week 16 - Solution


Solution by Tom Prowse and you can download the workflow here.


Following from looking at Easter Sunday dates last week, we are now going to look why there is so much variation with Easter dates and how the moon reflects this.

Step 1 - Tidy Full Moon Input

First, we want to input the Full_Moon table and rename the fields: 

- Day = Full Moon Day
- Date = Full Moon Date (make sure this is a Date field type)

We can then clean the Time field to match the requirements. First we want to remove all the Numbers and Letters from the field so we are left with only the symbols that represent the different types of moons.


Then we want to replace the symbols with the corresponding type of moon as given in the requirements. As a result we should now have the 4 different types of moons in our table: 


Step 2 - Include Easter Sunday

We can now include the dates for Easter Sunday by joining the Easters table using an inner join where Full Moon Date <= Easter Sunday: 


Now we have both tables together we can calculate the Days between the full moon and Easter: 

Days Between 
DATEDIFF('day',[Full Moon Date],[Easter Sunday])

Then we can calculate the closest (minimum) days for each Easter Sunday by using a Fixed LOD calculation: 


Then we can filter where [Days Between Full Moon & Easter Sunday]=[Days between] and this will get us a row for each Easter Sunday and the closest Full Moon Date for each.

As Easter only occurs once a year, we can convert the both of the dates to a Year



Step 3 - Aggregate for No. Days Between

To highlight some of the interesting facts about the different number of days between Easter and the Full Moons, we want to aggregate the data. 

For this we want to group by Days Between Full Moon & Easter Sunday, and then sum Number of Rows, Max Full Moon Notes, Min Full Moon Date, Max Easter Sunday


After the aggregation we can rename the following fields: 

- Full Moon Notes = Most Interesting Event
- Number of Rows = Number of Occurrences
- Full Moon Date = Min Year
- Easter Sunday = Max Year

Then we can sort the table using a Rank calculation where we rank the Days Between field: 



We can then hide the Sort field and are ready to output our data: 



After you finish the challenge make sure to fill in the participation tracker, then share your solution on Twitter using #PreppinData and tagging @Datajedininja@JennyMartinDS14 & @TomProwse1

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! 

Popular posts from this blog

2024: Week 1 - Prep Air's Flow Card

2023: Week 1 The Data Source Bank

How to...Handle Free Text