Created
December 26, 2022 19:54
-
-
Save ncalm/ab577ccda71b1f47601f85c3b462319d to your computer and use it in GitHub Desktop.
M queries to inspect enumeration documentation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| A simple query to get the list of enumerations | |
| */ | |
| let | |
| Source = Web.Page(Web.Contents("https://learn.microsoft.com/en-us/powerquery-m/enumerations")){0}[Data] | |
| in | |
| Source |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Query each of the web pages for enumeration documentation and return the list of allowed values | |
| */ | |
| let | |
| //URLs for documentation begin with this text | |
| URLPrefix = "https://learn.microsoft.com/en-us/powerquery-m/", | |
| //The URL of the index page for enumerations | |
| MainPage = URLPrefix & "enumerations", | |
| //Get the table of enumerations from the index page | |
| Source = Web.Page(Web.Contents(MainPage)){0}[Data], | |
| //Create a table structure to load the allowed values into | |
| EmptyTable = #table({"Name", "Value", "Description", "Enum", "URL"},{}), | |
| /* | |
| Iterate through the URLs, retrieve the table of allowed values and stack them on top of | |
| each other along with the URL and the Enum name | |
| */ | |
| GetAllowedTables | |
| = List.Accumulate( | |
| Source[Name], | |
| EmptyTable, | |
| (output,enum) => | |
| let | |
| URL = URLPrefix & Text.Replace(enum, ".", "-"), | |
| WebTable = Web.Page(Web.Contents(URL)){0}[Data], | |
| AddEnumName = Table.AddColumn(WebTable, "Enum", each enum), | |
| AddEnumURL = Table.AddColumn(AddEnumName, "URL", each URL) | |
| in | |
| Table.Combine({output,AddEnumURL}) | |
| ) | |
| in | |
| GetAllowedTables |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment