A
- AccessControlEntry.ConditionToIdentities
- Access.Database
- ActiveDirectory.Domains
- AdobeAnalytics.Cubes
- AdoDotNet.DataSource
- AdoDotNet.Query
- AnalysisServices.Database
- AnalysisServices.Databases
- AzureStorage.BlobContents
- AzureStorage.Blobs
- AzureStorage.DataLake
- AzureStorage.DataLakeContents
- AzureStorage.Tables
B
- BinaryFormat.Binary
- BinaryFormat.Byte
- BinaryFormat.ByteOrder
- BinaryFormat.Choice
- BinaryFormat.Decimal
- BinaryFormat.Double
- BinaryFormat.Group
- BinaryFormat.Length
- BinaryFormat.List
- BinaryFormat.Null
- BinaryFormat.Record
- BinaryFormat.SignedInteger16
- BinaryFormat.SignedInteger32
- BinaryFormat.SignedInteger64
- BinaryFormat.Single
- BinaryFormat.Text
- BinaryFormat.Transform
- BinaryFormat.UnsignedInteger16
- BinaryFormat.UnsignedInteger32
- BinaryFormat.UnsignedInteger64
- BinaryFormat.7BitEncodedSignedInteger
- BinaryFormat.7BitEncodedUnsignedInteger
- Binary data
- Binary.ApproximateLength
- Binary.Buffer
- Binary.Combine
- Binary.Compress
- Binary.Decompress
- Binary.From
- Binary.FromList
- Binary.FromText
- Binary.InferContentType
- Binary.Length
- Binary.Range
- Binary.Split
- Binary.ToList
- Binary.ToText
- Binary.View
- Binary.ViewError
- Binary.ViewFunction
- Byte.From
C
- Cdm.Contents
- Character.FromNumber
- Character.ToNumber
- Combiner.CombineTextByDelimiter
- Combiner.CombineTextByEachDelimiter
- Combiner.CombineTextByLengths
- Combiner.CombineTextByPositions
- Combiner.CombineTextByRanges
- Comparer.FromCulture
- Comparer.Ordinal
- Comparer.OrdinalIgnoreCase
- Controlling byte order
- Csv.Document
- Cube.AddAndExpandDimensionColumn
- Cube.AddMeasureColumn
- Cube.ApplyParameter
- Cube.AttributeMemberId
- Cube.AttributeMemberProperty
- Cube.CollapseAndRemoveColumns
- Cube.Dimensions
- Cube.DisplayFolders
- Cube.MeasureProperties
- Cube.MeasureProperty
- Cube.Measures
- Cube.Parameters
- Cube.Properties
- Cube.PropertyKey
- Cube.ReplaceDimensions
- Cube.Transform
- Currency.From
D
- DateTime.AddZone
- DateTime.Date
- DateTime.FixedLocalNow
- DateTime.From
- DateTime.FromFileTime
- DateTime.FromText
- DateTime.IsInCurrentHour
- DateTime.IsInCurrentMinute
- DateTime.IsInCurrentSecond
- DateTime.IsInNextHour
- DateTime.IsInNextMinute
- DateTime.IsInNextNHours
- DateTime.IsInNextNMinutes
- DateTime.IsInNextNSeconds
- DateTime.IsInNextSecond
- DateTime.IsInPreviousHour
- DateTime.IsInPreviousMinute
- DateTime.IsInPreviousNHours
- DateTime.IsInPreviousNMinutes
- DateTime.IsInPreviousNSeconds
- DateTime.IsInPreviousSecond
- DateTime.LocalNow
- DateTime.Time
- DateTime.ToRecord
- DateTime.ToText
- Date.AddDays
- Date.AddMonths
- Date.AddQuarters
- Date.AddWeeks
- Date.AddYears
- Date.Day
- Date.DayOfWeek
- Date.DayOfWeekName
- Date.DayOfYear
- Date.DaysInMonth
- Date.EndOfDay
- Date.EndOfMonth
- Date.EndOfQuarter
- Date.EndOfWeek
- Date.EndOfYear
- Date.From
- Date.FromText
- Date.IsInCurrentDay
- Date.IsInCurrentMonth
- Date.IsInCurrentQuarter
- Date.IsInCurrentWeek
- Date.IsInCurrentYear
- Date.IsInNextDay
- Date.IsInNextMonth
- Date.IsInNextNDays
- Date.IsInNextNMonths
- Date.IsInNextNQuarters
- Date.IsInNextNWeeks
- Date.IsInNextNYears
- Date.IsInNextQuarter
- Date.IsInNextWeek
- Date.IsInNextYear
- Date.IsInPreviousDay
- Date.IsInPreviousMonth
- Date.IsInPreviousNDays
- Date.IsInPreviousNMonths
- Date.IsInPreviousNQuarters
- Date.IsInPreviousNWeeks
- Date.IsInPreviousNYears
- Date.IsInPreviousQuarter
- Date.IsInPreviousWeek
- Date.IsInPreviousYear
- Date.IsInYearToDate
- Date.IsLeapYear
- Date.Month
- Date.MonthName
- Date.QuarterOfYear
- Date.StartOfDay
- Date.StartOfMonth
- Date.StartOfQuarter
- Date.StartOfWeek
- Date.StartOfYear
- Date.ToRecord
- Date.ToText
- Date.WeekOfMonth
- Date.WeekOfYear
- Date.Year
- DB2.Database
- Decimal.From
- Diagnostics.ActivityId
- Diagnostics.Trace
- DirectQueryCapabilities.From
- Double.From
- Duration.Days
- Duration.From
- Duration.FromText
- Duration.Hours
- Duration.Minutes
- Duration.Seconds
- Duration.ToRecord
- Duration.TotalDays
- Duration.TotalHours
- Duration.TotalMinutes
- Duration.TotalSeconds
- Duration.ToText
E
F
G
H
I
L
- Lines.FromBinary
- Lines.FromText
- Lines.ToBinary
- Lines.ToText
- List.Accumulate
- List.AllTrue
- List.Alternate
- List.AnyTrue
- List.Average
- List.Buffer
- List.Combine
- List.ConformToPageReader
- List.Contains
- List.ContainsAll
- List.ContainsAny
- List.Count
- List.Covariance
- List.Dates
- List.DateTimes
- List.DateTimeZones
- List.Difference
- List.Distinct
- List.Durations
- List.FindText
- List.First
- List.FirstN
- List.Generate
- List.InsertRange
- List.Intersect
- List.IsDistinct
- List.IsEmpty
- List.Last
- List.LastN
- List.MatchesAll
- List.MatchesAny
- List.Max
- List.MaxN
- List.Median
- List.Min
- List.MinN
- List.Mode
- List.Modes
- List.NonNullCount
- List.Numbers
- List.Percentile
- List.PositionOf
- List.PositionOfAny
- List.Positions
- List.Product
- List.Random
- List.Range
- List.RemoveFirstN
- List.RemoveItems
- List.RemoveLastN
- List.RemoveMatchingItems
- List.RemoveNulls
- List.RemoveRange
- List.Repeat
- List.ReplaceMatchingItems
- List.ReplaceRange
- List.ReplaceValue
- List.Reverse
- List.Select
- List.Single
- List.SingleOrDefault
- List.Skip
- List.Sort
- List.Split
- List.StandardDeviation
- List.Sum
- List.Times
- List.Transform
- List.TransformMany
- List.Union
- List.Zip
- Logical.From
- Logical.FromText
Understanding List.Accumulate
Before we dive into the M code behind List.Accumulate, it is important to understand how the function works. List.Accumulate takes three arguments:
– The first argument is a list of values that the function will process.
– The second argument is an initial state value that will be used as the starting point for the accumulation.
– The third argument is a function that will be applied to each element in the list, along with the current accumulated state value.
The function will process each element in the list, applying the custom function to the current element and the accumulated state value. The result of this operation will become the new accumulated state value, which will be used as the input for the next iteration of the function. This process is repeated until all elements in the list have been processed, at which point the final accumulated state value is returned as the result.
The M Code Behind List.Accumulate
The M code behind List.Accumulate is relatively simple, but it can be a bit daunting for those who are new to Power Query or programming in general. Here is an example of the M code for a simple List.Accumulate function:
let
Source = {1..10},
AccumulateFunction = (state, current) => state + current,
Result = List.Accumulate(Source, 0, AccumulateFunction)
in
Result
In this example, we are using List.Accumulate to find the sum of a list of numbers from 1 to 10. Here is what each line of the code does:
- The first line sets the Source variable to a list of values from 1 to 10.
- The second line defines the AccumulateFunction variable, which is a custom function that takes two arguments (state and current) and returns the result of adding them together.
- The third line applies the List.Accumulate function to the Source list, using an initial state value of 0 and the AccumulateFunction as the custom function.
When we run this code, the Result variable will be set to the final accumulated state value, which in this case is the sum of the numbers from 1 to 10 (55).
Advanced Uses of List.Accumulate
List.Accumulate can be used in a wide variety of scenarios beyond simple calculations, including data transformations, data cleaning, and more. Here are a few examples of how List.Accumulate can be used in more advanced scenarios:
Data Transformations
List.Accumulate can be used to transform data within a list. For example, you could use List.Accumulate to extract a specific value from each element in a list and accumulate those values into a new list. Here is an example of how this could be done:
let
Source = {{“John”, 25}, {“Jane”, 30}, {“Bob”, 40}},
AccumulateFunction = (state, current) => state & List.Transform({current{0}} & “, “),
Result = List.Accumulate(Source, “”, AccumulateFunction)
in
Result
In this example, we are using List.Accumulate to extract the names from a list of name/age pairs and accumulate them into a comma-separated list. Here is what each line of the code does:
- The first line sets the Source variable to a list of name/age pairs.
- The second line defines the AccumulateFunction variable, which extracts the name from each pair and adds it to the accumulated state value as a comma-separated string.
- The third line applies the List.Accumulate function to the Source list, using an initial state value of an empty string and the AccumulateFunction as the custom function.
When we run this code, the Result variable will be set to the final accumulated state value, which in this case is "John, Jane, Bob".
Data Cleaning
List.Accumulate can also be used to clean data within a list. For example, you could use List.Accumulate to remove unwanted characters from a list of strings and accumulate the cleaned strings into a new list. Here is an example of how this could be done:
let
Source = {“123-456-7890”, “555-555-5555”, “(999) 999-9999”},
AccumulateFunction = (state, current) => state & Text.Replace(current, “-“, “”) & “, “,
Result = List.Accumulate(Source, “”, AccumulateFunction)
in
Result
In this example, we are using List.Accumulate to remove dashes from a list of phone numbers and accumulate the cleaned phone numbers into a comma-separated list. Here is what each line of the code does:
- The first line sets the Source variable to a list of phone numbers.
- The second line defines the AccumulateFunction variable, which removes dashes from each phone number and adds the cleaned number to the accumulated state value as a comma-separated string.
- The third line applies the List.Accumulate function to the Source list, using an initial state value of an empty string and the AccumulateFunction as the custom function.
When we run this code, the Result variable will be set to the final accumulated state value, which in this case is "1234567890, 5555555555, 9999999999".
List.Accumulate is a powerful tool for processing lists of values in Power Query. By understanding the M code behind List.Accumulate and exploring its advanced uses, you can unlock new possibilities for data transformations and cleaning within your own Power Query workflows.