By the end of this chapter you will be able to:
- Create macros
- Use macros
Creating macros
Macros are used to create reusable expressions. They can be thought of as, the ability to write bespoke functions. Macros can optionally take in a number of parameters to use within its expression:
- Find Macros in the repository
- Right-click and select Add Macro
- Configure the macro:
- Press Apply and Close to save your new macro
Using Macros
- Create a new model:
Try Macros
- Drag the table
MC Macro Terminated Customers
on to your model- This contains some key dates for terminated customers: the signup date; the date that the customer terminated their service; the date that the final debt on the customer's account was cleared
- Add Attributes for:
- the number of weeks between signup and termination
- the number of weeks between termination and the final debt being cleared
In each case, use your macro to calculate the number of weeks between the two dates
- Run the table
MC Macro Terminated Customers
to test your new attributes