Skip to main content

Posts

Showing posts with the label m language

PowerBI Create a date table in Power Query (M)

In another blog post, I covered ' How to create a Date Table using DAX ' which is one of the most common ways to create a date table in PowerBI. Another method that might be of interest is to create the table using Power Query. Anyone who has used Power Query will know that although it can achieve a similar output to DAX the process is very different. In this post, I'll show you how to create a relatively basic Date Table in Power Query that will contain a list of dates and 5 additional columns with the dates associated with the end of the month, quarter, week, year and fortnight. The process is to create a list of dates and then add custom columns for each of the additional columns that we want to include in the date table Although the most common way of creating a date table appears to be within DAX, I thought this would be an interesting exercise to see what is possible in Power Query (M). Date tables in DAX are expertly covered by the guys over at SQLBI in their article...

Use Power Query (M Language) to scrape a web page and output it to a CSV file

When using PowerQuery / M / PowerBI to scrape web pages, it's often useful to output the data to a CSV file. This enables the recording of multiple scrapes (with the time stamp in the filename) and also makes transformation and reloading more efficient. Below is a piece of M code I recently used to capture a webpage and record its details to a CSV file. This is a simplified piece of code to demonstrate the application, if there are additional transformations that are required, these can be done before the RScript line/step in the code. Click here to download the file in the this example let     Source = Web.BrowserContents("www.bbc.co.uk"),           #"Extracted Table From Html" = Html.Table(Source, {{"Column1", ".module--highlight .media__link"}, {"Column2", ".module--highlight .media__tag"}, {"Column3", ".module--highlight .block-link__overlay-link"}, {"Column4", ".module--hig...