Beast Mode to compare Values in 1 Column against 2 time periods
I have access to a dataset at my organization that pulls in competitor data.
The question I want to answer with my card is:
- Who is/are the new competitor(s) that showed up last week (fully completed week) compared to competitors from last 12 weeks (exluding the prior completed week)
I have built out a dash that starts at a high level (period over period line bar chart) that shows # of competitors by week and the WoW variance on the secondary axis. I also have some aggregate level competitor metric charts built out too.
What I want to do next is go a little bit deeper and build out a table that will show who are the NEW competitors last week
These are the primary columns in my dataset that I will be using (bolded would be what I will use for the pivot table - the metrics were for the charts I made):
- Column A is Date (by Day)
- Column B is Competitor
- Column C is Metric 1
- Column D is Metric 2
Conceptually, I want to build this out via a pivot table
- "Column B aka Competitors" Will be a row
- The "Values" Column is where I would like to build out a Beast Mode. I've been trying to build a beast mode that will:
- Look at Last Week's Competitors compared to all competitors from the previous 12 weeks (excluding last week).
- If last week's competitor is NEW then mark it with a 1 and if they are not new, mark it with a 0
- add a filter to only show values with "1" since the pivot table can't return "strings".
It would probably look better if I could bucket new competitors as "NEW" and existing as "Existing" but I couldn't get my pivot to return those values when I did a rudimentary beast mode attempt.
The finished table will only list the competitors who are new/have a "1" flag. for the value, I'm fine with it just saying 1.
I have been tinkering with my beast mode for the better part of the work day without avail so here I am . I think I am bungling these "nested" case statements quite badly...
CASE WHEN WEEK(`Date`) = WEEK(CURRENT_DATE()) - 1 then `Competitor` <> 'Competitor' WHEN WEEK(`Date`) > WEEK(CURRENT_DATE()) - 14 and WEEK(CURRENT_DATE()) < WEEK(CURRENT_DATE()) - 1 THEN '1' ELSE '0' END
I'm just trying to make it look at competitors from last week compared to last "14" weeks since I won't be counting the previous week...