Extension columns are columns that you add to existing tables. You can obtain extension columns by
using both ADDCOLUMNS and SUMMARIZE. Basically these functions adds columns / tables over the conditions applied.
For example, the following query adds a Year Production column to the rows returned from the Product table.
For example, the following query adds a Year Production column to the rows returned from the Product table.
EVALUATE
ADDCOLUMNS
(
Product
,
"Year Production"
,
YEAR
(
Product[Product Start Date]
)
)
In below query, you can count the number of products for each product category by using the following query
EVALUATE
SUMMARIZE
(
Product
,
Product[Product Category Name]
,
"Products"
,
COUNTROWS
(
Product
)
)
For performance reasons it is better to add ADDCOLUMNS() outside.
SUMMARIZECOLUMNS: Returns a summary table over a set of groups.
EVALUATE
ADDCOLUMNS
(
SUMMARIZE
(
Product
,
Product[Product Name]
,
Product[Product Start Date]
)
,
"Year Production"
,
YEAR
(
Product[Product Start Date]
)
)
Below query returns the sumofsales for calendar year and category name
Summarize =
SUMMARIZECOLUMNS(
'Calendar'[Year],
Categories[CategoryName],
"sumofsales", [Sales])
Thanks, :)
No comments:
Post a Comment