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 Cube.ReplaceDimensions Function
Cube.ReplaceDimensions is a Power Query M function that is used to replace dimensions in a cube. It takes in three arguments: Cube, OldDimension, and NewDimension. The Cube argument specifies the cube that needs to be transformed. The OldDimension argument specifies the dimension that needs to be replaced, while the NewDimension argument specifies the replacement dimension.
The syntax for the Cube.ReplaceDimensions function is as follows:
Cube.ReplaceDimensions(Cube as any, OldDimension as any, NewDimension as any) as any
Here, the 'as any' keyword is used to specify that the arguments can take any data type.
The M Code Behind Cube.ReplaceDimensions
To understand the M code behind Cube.ReplaceDimensions, we need to understand how it works. Cube.ReplaceDimensions function replaces a dimension in a cube with a new dimension. It does this by creating a new cube that has the new dimension and then copying the data from the old cube to the new cube.
The M code behind Cube.ReplaceDimensions function can be broken down into the following steps:
1. Get the CubeData: The CubeData is the data that needs to be transformed. It is obtained by calling the Cube.GetCubeData function.
2. Get the OldDimensionData: The OldDimensionData is the data that needs to be replaced. It is obtained by calling the Cube.GetDimensionData function.
3. Get the NewDimensionData: The NewDimensionData is the replacement data. It can be obtained from a table or by calling another function that returns a table.
4. Replace the OldDimensionData with the NewDimensionData: This is done by using the Table.ReplaceMatchingRows function to replace the OldDimensionData with the NewDimensionData.
5. Create a new CubeData: The new CubeData is created by using the Cube.ReplaceDimensionData function. This function takes in the old CubeData and the new dimension data and creates a new CubeData.
6. Return the new CubeData: The new CubeData is returned as the output of the Cube.ReplaceDimensions function.
Example
Let's take an example to understand how Cube.ReplaceDimensions function works. Suppose we have a cube that contains sales data by region and product. The dimensions are Region and Product. We want to replace the Region dimension with a new dimension called Country. The new dimension contains the same data as the Region dimension but is grouped by country instead of region.
To do this, we can use the following M code:
let
CubeData = Cube.GetCubeData(“Sales Cube”),
OldDimensionData = Cube.GetDimensionData(CubeData, “Region”),
NewDimensionData = GetCountryDimensionData(),
NewCubeData = Cube.ReplaceDimensionData(
CubeData,
“Region”,
NewDimensionData
),
Output = Cube.ReplaceDimensions(
CubeData,
“Region”,
NewDimensionData
)
in
Output
Here, we first get the CubeData using the Cube.GetCubeData function. Then we get the OldDimensionData using the Cube.GetDimensionData function. We get the NewDimensionData by calling the GetCountryDimensionData function (which returns a table). We then use the Cube.ReplaceDimensionData function to create a new CubeData with the new dimension data. Finally, we use the Cube.ReplaceDimensions function to replace the old dimension with the new dimension in the cube.
In this article, we have delved into the M code behind the Power Query M function Cube.ReplaceDimensions. We have seen that this function is used to replace dimensions in a cube and that it works by creating a new cube with the new dimension and copying the data from the old cube to the new cube. We have also seen an example of how this function can be used to replace a dimension in a cube. With this knowledge, users can use the Cube.ReplaceDimensions function to transform data in Power Query.