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
| let | |
| fxTrim = (string as nullable text, optional addPunctuationMarks as text) as text => | |
| [ | |
| baseMarks = ".,;:?!'-–—_", | |
| marks = Text.ToList(baseMarks & (addPunctuationMarks ?? "")), | |
| clean = Text.Combine( | |
| List.Transform( | |
| Splitter.SplitTextByCharacterTransition(each true, marks)(string), | |
| Text.Trim | |
| ) |
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
| let | |
| /* The July 2025 update to the documentation now mentions a MissingField type for Table.TransformColumnTypes */ | |
| /* Here's sample data, a table with two columns: Date and Value */ | |
| Source = #table( | |
| type table [Date = date, Value = number], | |
| { | |
| {#date(2024, 3, 12), 0.24368}, | |
| {#date(2024, 5, 30), 0.03556}, | |
| {#date(2023, 12, 14), 0.3834} | |
| } |
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
| let | |
| /* Samples */ | |
| myRecord = [#"1"=1, Two=2], | |
| myTable = Table.FromColumns({{0..2}, {3..5}}), | |
| /* Record | Field Selection or Lookup */ | |
| RecRequiredFieldAccess = [#"1"=1, Two=2][Two], | |
| RecRequiredFieldAccess2 = [#"1"=1, Two=2][Beep], | |
| RecOptionalFieldAccess = [#"1"=1, Two=2][Beep]?, |
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
| let | |
| /* Samples */ | |
| myList = {0..4}, | |
| myTable = Table.FromValue({0..4}), | |
| /* List | Item Access */ | |
| ListRequiredItemAccess = {0..4}{1}, | |
| ListRequiredItemAccess2 = {0..4}{10}, | |
| ListOptionalItemAccess = {0..4}{10}?, |
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
| let | |
| fxFindMinMaxDates = (tableNames as list, optional dateColsID as text, optional excludeDateColNames as list) as record => | |
| let | |
| selectedTables = Record.SelectFields( | |
| #sections[Section1], | |
| tableNames, | |
| MissingField.Ignore | |
| ), | |
| rawData = Table.RemoveColumns( | |
| Table.Combine(Record.ToList(selectedTables)), |
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
| let | |
| fxExtractEightDigitSequence = let | |
| extractEightDigitSequence = (txt as nullable text, optional Occurrence as number) => | |
| let | |
| input = txt ?? "", | |
| parts = Text.SplitAny(input, Text.Remove(input, {"0" .. "9"})), | |
| digits = List.Select(parts, each Text.Length(_) = 8) | |
| in | |
| {List.First(digits), List.Last(digits), digits}{(Occurrence ?? 0)}, | |
| extractEightDigitSequenceType = type function ( |
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
| let | |
| extractCharactersByCase = (input as nullable text, optional caseType as text) as text => | |
| Text.Combine( | |
| List.Select( | |
| Text.ToList(input ?? ""), | |
| (s) => | |
| if Text.Proper(caseType ?? "Upper") = "Upper" | |
| then not (Text.Lower(s) = s) | |
| else not (Text.Upper(s) = s) | |
| ) |
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
| var dateTableName = "Dates"; // Name of your date table | |
| var dateKeyColName = "Date"; // Name of the date key column in the table | |
| var colOperations = new List<Tuple<string, string, bool>>(){ | |
| Tuple.Create("Quarter & Year", "QuarternYear", true), | |
| Tuple.Create("Month & Year", "MonthnYear", true), | |
| Tuple.Create("Month Name", "MonthOfYear", true), | |
| Tuple.Create("Month Short", "MonthOfYear", true), | |
| Tuple.Create("Month Initial", "MonthOfYear", true), | |
| Tuple.Create("Week & Year", "WeeknYear", true), | |
| Tuple.Create("Day of Week Name", "DayOfWeek", true), |
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
| let | |
| fnDateTable = ( StartDate as date, EndDate as date, optional FYStartMonthNum as number, optional Holidays as list, optional WDStartNum as number, optional AddRelativeNetWorkdays as logical ) as table => | |
| let | |
| FYStartMonth = List.Select({1..12}, each _ = FYStartMonthNum){0}? ?? 1, | |
| WDStart = List.Select({0..1}, each _ = WDStartNum){0}? ?? 0, | |
| CurrentDate = Date.From(DateTimeZone.FixedUtcNow()), | |
| DayCount = Duration.Days(Duration.From(EndDate - StartDate)) + 1, | |
| weekStart = Day.Monday, | |
| HolidaysProvided = Holidays <> null, |
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
| let | |
| /* Function to convert an input value like a date, datetime, datetimezone, or text to a target type */ | |
| convertDateTo = let | |
| fxConvertDateTo = (Value as any, ReturnType as text, optional Culture as any, optional formatString as text) as any => | |
| let | |
| Separators = Text.Combine(List.Select( | |
| Text.ToList(Text.Remove(Text.From(Value) ?? "", {"0" .. "9"})), | |
| each Text.Lower(_) = Text.Upper(_) ) | |
| ), | |
| c = Culture ?? Culture.Current, |
NewerOlder