DAX Aggregation - GENERATE function


Advertisements

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

Useful Video Courses


Video

Mastering DAX and Data Models in Power BI Desktop

53 Lectures 5.5 hours

Abhay Gadiya

Video

Mastering DAX Studio

Featured

24 Lectures 2 hours

Randy Minder

Video

DAX / Power BI - Customer and Sales Analysis Deep Dive

26 Lectures 4.5 hours

Randy Minder

Advertisements