Value.ResourceExpression is a Power Query M function that generates a record given a value’s resource expression.
Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365
Syntax
Value.ResourceExpression( value as any ) as any
Description
The Value.ResourceExpression function generates a record representing a given value’s resource expression. This function is useful for inspecting the structure or metadata of values, especially functions and constants, within the Power Query M language.
Examples
Let’s explore how we can use the Value.ResourceExpression function.
Did you know that the List.RemoveFirstN function is essentially a syntax sugar for List.Skip? We can confirm this by using the following expression:
/* Returns:
[ Kind = Identifier, Name = List.Skip, IsInclusive = false ] */
Value.ResourceExpression(
List.RemoveFirstN
)
This expression returns a record with the fields Kind
, Name
and IsInclusive
. The Name field shows us that List.RemoveFirstN maps to its public equivalent List.Skip.
In a similar way, if we pass the Replacer.ReplaceText function to Value.ResourceExpression, it reveals that Power Query M actually uses the Text.Replace function:
/* Returns:
[ Kind = Identifier, Name = Text.Replace, IsInclusive = false ] */
Value.ResourceExpression(
Replacer.ReplaceText
)
This Name field tells us that Replacer.ReplaceText corresponds to Text.Replace in the M language.
Now, let’s see what happens when we pass an actual value (a constant) to the function:
/* Returns
[ Kind = Constant, Value = "Bye Rick" ] */
Value.ResourceExpression(
Replacer.ReplaceText( "Hello Rick", "Hello", "Bye" )
)
In this case, the function evaluates the expression and returns a record indicating that the Kind
is "Constant"
and the Value
is "Bye Rick"
.
By using Value.ResourceExpression, we can peek under the hood of functions and expressions in Power Query M, helping us understand how they work or how they’re connected to other functions.
Related functions
Other functions related to Value.ResourceExpression are:
- Value.Alternates
- Value.Expression
- Value.Lineage
- Value.Traits
- Value.Type
- Value.VersionIdentity
- Value.Versions
2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy