This file contains 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
/* | |
GETBIGRAMS - Get the bigrams of a text string | |
Inputs: 1. str - a text string | |
Returns: A vertical array of the bigrams of the text string | |
Example: | |
=GETBIGRAMS("banana") | |
={"ba";"an";"na";"a"} | |
*/ |
This file contains 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
function main(workbook: ExcelScript.Workbook) { | |
const activeSheet = workbook.getActiveWorksheet() | |
// Returns an object representing the worksheet's protection | |
const activeSheetProtection = activeSheet.getProtection() | |
// Protect the sheet according to preferred options (password as 2nd arg is optional) | |
// This line uses the ternary operator. The protect call is only used if the getProtected() call returns false |
This file contains 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
/* | |
* Create and format a chart from some AdventureWorksDW2019 data | |
* The table has these columns: Year, Month, SalesAmount | |
* The worksheet must include a named cell called 'referenceLineValue'. This value is used to draw the line on the chart. | |
*/ | |
function main(workbook: ExcelScript.Workbook) { | |
let selectedSheet = workbook.getActiveWorksheet(); |
This file contains 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
/* | |
GROUPAGGREGATE | |
Creates summary tables of data similar to SQL's GROUP BY queries | |
Inputs | |
- dat: a range or array of data with at least two columns, | |
one of which's control value must be "group" and one not "group" | |
- control: a single-row array, where COLUMNS(control)=COLUMNS(dat), of values from this list: | |
group - the values in this column will be output as row headers |
This file contains 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
RGB2HEX = LAMBDA(rgb_array, | |
LET( | |
_rgb_array,TOROW(0+rgb_array), | |
IF(COUNT(_rgb_array)<>3,#VALUE!, | |
CONCAT("#",DEC2HEX(_rgb_array,2)) | |
) | |
) | |
); |
This file contains 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
let | |
Source = "APS Deposit 04/01/2022 $5,174.27 APS ACH Deposit 04/04/2022 $65,186.66", | |
Split = Text.Split(Source, " "), | |
Typed = List.Transform(Split, | |
each try Number.From(_) otherwise | |
try Date.From(_, "en-gb") otherwise _ ), | |
Accumulate = List.Accumulate({0..List.Count(Typed)-1}, "", | |
(a, b) => | |
let | |
c = Typed{b}, |
This file contains 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
/* | |
Author: Owen Price | |
Date: 2022-09-17 | |
https://www.flexyourdata.com/ | |
Handles multi-level nested column headers, optionally combines them into a single header row and optionally promotes the first row to the column header of the resulting table. | |
*/ | |
let | |
func = |
This file contains 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
AreWeThereYet = LAMBDA(date, | |
LET( | |
n, NOW(), | |
days, date - n, | |
countdown, INT(days) & " days, " & | |
TEXT(days, "h"" hours ""m"" minutes ""s"" seconds"""), | |
working_days, NETWORKDAYS(n, date), | |
working_hours, working_days * 8, | |
hours, days * 24, | |
minutes, days * 24 * 60, |
This file contains 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
namespace_author = "Owen Price"; | |
namespace_author_url = "https://www.flexyourdata.com"; | |
namespace_description="This namespace provides functionality for building depreciation schedules"; | |
schedule_demo = depn.schedule(100000,10000,6,2015,depn.db,true,depn.byyear,true); | |
schedule_header = {"Period labels","Periods","Depreciation","Accumulated Depreciation","Depreciated Asset Value"}; | |
/* | |
Author: Owen Price | |
https://www.flexyourdata.com |
This file contains 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 |