GENERATEALL
As GENERATE, keeping the rows that get none, with blanks.
Group: Table manipulation. Compatible with DAX.
Syntax
GENERATEALL ( <table1>, <table2> )
| Parameter | Type | Description |
|---|---|---|
table1 | Table | The rows to start from; every one of them appears in the result. |
table2 | Table evaluated for each row | The table worked out for each row of the first; it can use that row's columns. |
Returns
Table. Each row of the first table paired with each row its second table gives; a row whose second table is empty appears once, with blanks on the right.
Remarks
- It is
GENERATEthat never loses a row of the first table, as a left outer join never loses a row of the left table. - As in GENERATE, wrap table functions of the second argument in
CALCULATETABLEwhen the row should filter them. - The two tables must not share a column name.
Examples
One row per crate, every shop listed
Storo fills no slot: it appears once, with a blank slot.
EVALUATE
VAR Shops =
DATATABLE (
"Shop", STRING, "Crates", INTEGER,
{ { "Frogner", 2 }, { "Storo", 0 }, { "Sagene", 1 } }
)
VAR Slots = DATATABLE ( "Slot", INTEGER, { { 1 }, { 2 }, { 3 } } )
RETURN
GENERATEALL ( Shops, FILTER ( Slots, [Slot] <= [Crates] ) )
ORDER BY [Shop], [Slot]
| Shop | Crates | Slot |
|---|---|---|
| Frogner | 2 | 1 |
| Frogner | 2 | 2 |
| Sagene | 1 | 1 |
| Storo | 0 | (blank) |
A category with no product over half a million liters
No cider sold more than 500,000 liters, so the Cider row has a blank product.
EVALUATE
GENERATEALL (
VALUES ( Products[Category] ),
CALCULATETABLE (
TOPN ( 1, FILTER ( VALUES ( Products[Product] ), [Liters sold] > 500000 ), [Liters sold] )
)
)
ORDER BY Products[Category]
| Products[Category] | Products[Product] |
|---|---|
| Beer | Pils |
| Cider | (blank) |