As the amount of code snippets got a little bit messy, I decided to put all of the commonly used and referred code snippets together in a repository on GitHub. I differentiate between the Power BI or DAX measures and the Power Query or M snippets. For that reason I created two separate folders. The following table will give an overview over the provided examples
DAX-Snippet | Description |
---|---|
Correct column YYYY/MM for ISO format | When you use the ISO format the combination of YYYY/MM is wrong at the end of the year. For example for the first week of 2021 the result would be "2021/53" instead of "2020/53". This snippet is correcting this error |
DateTable with date column in fact table | Snippet to create a correct date table based on the date range in a fact table. |
DateTable with date ID in fact table | Snippet to create a correct date table based on the date range in a fact table when the fact table only contains date IDs (e.g. 20201030). |
ISO calender week | DAX snippet to create the correct ISO week as calculated column |
M-Snippet | Description |
---|---|
DateID from Date | Create the date ID in the format YYYYMMDD from a date column |
Date from UNIX-Timestamp | If you get the date as UNIX-timestamp and you want to create a proper date from it |
ISO-Week from date | Function to get the ISO week from a column in DATE format |
Time table with buckets | The easiest way to create a time table is in M. Just use this snippet to create an universal time table with buckets for 5, 15 and 30 minutes |