While building Power Apps, sometimes we come across some Field names which are part of the data source and also same name used for a control or a new column added with AddColumns() function or a column within your collections, then Power Apps needs to identify which column we are actually referring to within you PowerFx functions such as Filter(), Sum() and so on.
To avoid the confusion and access appropriate value, Power Apps provided @ disambiguation operator to access the values from outside the record scope.
To access global values:
To access global values such as data sources, collections and context variables, use the pattern [@ObjectName]
For Example:
In the Power App, I have a slider and its name is Slider1. Also, I have a table with a column named Slider1.
When I am filtering table’s Slider1 column data based on Slider1 value, I need to use Filter() function as below:
Filter(SampleTable,slider1.Value = [@Slider1].Value )
[@Slider1] is used to refer specifically to the global name, which refers to the global slider1 control’s value. Whereas, in the case of slider1.Value, slider1 refers to the column in the SampleTable.
To access values from nested record scopes:
To access values from nested record scopes, use the @ operator with the name of the table using the following pattern:
Table[@FieldName]
This is very helpful in some cases where we write formulas with nested aggregates that operate on tables with colliding names.
For Example:
When a column “CustomerID” exists in both Customers and Orders, according to the PowerApps language’s scoping rules, the innermost row scope obscures the outer row scope.
When we try to access such colliding field names within the innermost scope, we can use this disambiguation syntax to refer to either the inner or the outer fields explicitly.
Filter(Order, Amount < LookUp(Customers, CustomerID = Orders[@CustomerID],TypicalAmount))
In the above formula, CustomerID refers to the field in the innermost row scope(i.e, a field in Customers) where as Orders[@CustomerID] refers to the corresponding CustomerID field in the outermost row scope (i.e., a field in Orders)
Reference:
Leave a Reply