This script must be executed from Tabular Editor. Go to tabulareditor.com to download it.
this script creates a calculation group in power bi (or any analysis services model, but haven't tried) to make time calculations on any measure or certain measures if you specify then, either by selecting them or typing their names.
To execute the script, open tabular editor from the power bi model you want to modify or open tabular editor and connect to the instance of analysis services (most likely your local power bi file) and open the script file from the advaced scripting tab, or copy-paste it there.
Follow the instructions specified in the code
For more information on this script read http://www.esbrina-ba.com/time-intelligence-the-smart-way/
Feel free to modify it the way you like and remember, no warranty!
Ping me on twitter if you have any doubts: @AgulloBernat