GENERATE Function (DAX)

How does the GENERATE function (DAX) work?

It returns a table with the Cartesian product between each row in table 1 and the table resulting from the assessment of table 2 in the context of the current row from table 1.

GENERATE Formula Syntax

GENERATE(<table1>, <table2>) 

How do you use the GENERATE function?

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

Related Blog Posts

create-a-table-in-power-bi
How-To-Harvest-Power-BI-Slicer-Selections-To-Use-Within-Other-Measures
Power-BI-WHAT-IF-Parameters

Related Support Forum Posts

Advanced Table Functions: GENERATE
Less Commonly Used Advanced Table Functions
Summarize not showing all data

Considerations when using the GENERATE function

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.

Related Video Tutorials

EDNA-TV-show-last-3-sales
creating-great-color-palettes-for-power-bi-data-visualization-tips

Formula examples using the GENERATE function

GENERATE(  
 SUMMARIZE(SalesTerritory, SalesTerritory[SalesTerritoryGroup])  
 ,SUMMARIZE(ProductCategory   
 , [ProductCategoryName]  
 , "Reseller Sales", SUMX(RELATEDTABLE(ResellerSales_USD), ResellerSales_USD[SalesAmount_USD])  
 )  
 )

Related DAX Functions

GENERATEALL
GENERATESERIES

Related Course Modules

Ultimate-Beginners-Guide-To-PowerBI

DOWNLOAD

To access our comprehensive DAX formula reference guide just insert your email address below. The resource will download immediately and we’ll also email it to you.