DAX Aggregation - GENERATE function



Description

Returns a table with the Cartesian product between each row in table1 and the table that results from evaluating table2 in the context of the current row from table1.

Syntax

GENERATE (<table1>, <table2>)

Parameters

Sr.No. Parameter & Description
1

table1

Table or a DAX expression that returns a table.

2

table2

Table or a DAX expression that returns a table.

Return Value

A table that can be passed as a parameter to a DAX function.

Remarks

  • If the evaluation of table2 for the current row in table1 returns an empty table, then the result table will not contain the current row from table1. This is different than GENERATEALL () where the current row from table1 will be included in the results, and columns corresponding to table2 will have null values for that row.

  • All column names from table1 and table2 must be different or an error is returned.

Example

= GENERATE ( 
   SUMMARIZE(Salesperson,Salesperson[Salesperson]),
      SUMMARIZE(SalesTarget,SalesTarget[SalesTarget],
      "MaxTarget",MAX(Sales Target[SalesTarget]))
)
dax_functions_aggregation.htm
Advertisements