Best Of
Re: Magic ETL Organization Tools
Yes! I love these ideas. These are things I would love, as a Magic user myself, and they're frequent asks from other customers as well. I'm actively reviewing these ideas with my engineering team.
Re: Remove lookback period from the data and see the values.
Thanks a lot @david_cunningham for the help!! I hope there was multi selection of reactions, so I could've selected 'Insightful', 'Like', 'Awesome'.
Re: Using regexp for pulling multiple values out a text string
Try something like this to make it a bit simpler:
REPLACE(REGEXP_REPLACE(SPLIT_PART(SPLIT_PART(``, 'Sent:', 1), 'To: ', 2), '[^<]+<([^>]+>)', '$1'), '>', ',')
SPLIT_PART(``, 'Sent:', 1)
Gets evertying in your string before 'Sent: ' - drops everything after it
SPLIT_PART(SPLIT_PART(``, 'Sent:', 1), 'To: ', 2)
Gets the entire text in between the To: and Sent: values so you're left with just the email addresses and the aliases
REGEXP_REPLACE(…, '[^<]+<([^>]+>)', '$1')
Finds all occurrences of the email addresses and any values outside of the < > and drops it in favor of what's in the < >. This keeps the trailing > so we can replace it with REPLACE in the last step with commas.
Re: Case Statement - 28 Days from a specific date?
I wanted to write up a more consolidated and easy to follow answer for anyone else curious about how to do this. This answer also expands on the requested functionality, by adding in a toggle that will allow users to flip between limiting the data based on a selected date, and showing all data. As well as allows users to specify the number of days to calculate back from the selected date.
We can use variables to allow users to select a date that will then limit the data shown. In this case, we are being asked to set it up so that the previous 28 days of data is shown based on the user selected date.
Step 1-1: Create a variable (SELECTED_DATE) that will be used as a control to let users select a date.
Step 1-2: Create another variable (USE_SELECTED_OR_ALL) that will be used as a control to let users toggle between selecting a date, and showing all data. Set up 2 options (Selected Date & All Dates) for this variable.
Step 2: Use the SELECTED_DATE and USE_SELECTED_OR_ALL variables in a case statement. This case statement will be used as a filter in Analyzer. I called this Beast Mode (RELEVANT_DATA_FILTER)
CASE
WHEN USE_SELECTED_OR_ALL = 'Selected Date'
THEN
CASE WHEN date >= DATE_SUB(SELECTED_DATE,interval 28 day) and date < SELECTED_DATE THEN 'Include' ELSE 'Exclude' END
ELSE 'Include'
END
Step 3: Use RELEVANT_DATA_FILTER as a filter on the card in Analyzer. You will want to select the value "Include" for the filter.
Step 4: Put your card on a dashboard, and then load in the controls so that users can interact with them.
If a user selects "All Dates" the card will show data for all dates. The cool thing here is that users will still be able to use the date range controls on the dashboard to control how the data is displayed (by day, month), and what range is displayed (current month, YTD, etc).
If a user selects "Selected Date" they can then select the date from which they want to show the previous 28 days of data from.
Note, you can change your variables default values. For example, you can set USE_SELECTED_OR_ALL to default to "All Dates" or "Selected Dates" depending on your use case.
You could take this even further, and create another variable (DAYS_TO_EVALUATE) that would let users dynamically change the number of days from the selected date that are shown. To do this, you would simply replace the hard-coded value of 28 in the case statement with your variable, and then include that variable on your dashboard as a control.
CASE
WHENUSE_SELECTED_OR_ALL= 'Selected Date'
THEN
CASE WHENdate>= DATE_SUB(SELECTED_DATE,interval DAYS_TO_EVALUATE day) anddate<SELECTED_DATETHEN 'Include' ELSE 'Exclude' END
ELSE 'Include'
END
Hope this is helpful to anyone who reads it! Feel free to reach out directly via message with any questions 😁
Re: Case Statement - 28 Days from a specific date?
@pauljames - that beast mode is included as an image above, but also pasting it below for your reference.
case when close_date >= DATE_SUB(START_DATE,interval 28 day) and close_date < START_DATE then 'Include' else 'Exclude' end
START_DATE is what I called the variable, and close_date is the dates you're filtering on with the control.
You would then filter on that beast mode in Analyzer to "Include" to make sure only dates that are 28 days from the selected date are shown.
Re: Case Statement - 28 Days from a specific date?
@pauljames - you can use variables to accomplish this.
So you would set up a variable that you could put on a dashboard as a control.
Then you would create a beast mode that references this variable (above)
You can see that above our data currently starts at 1/30 and goes back 28 days.
If I switch the date to 2/29, you can see that the data changes to start at 2/28 and goes back 28 days.













