cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted

hierarchy with measures??!!

Assume that we need to create a hierarchy that has Category, subcategory, and product, based on the data model below: 1.png

 

 

we all know that creating hierarchy is possible with adding a calculated column with RELATED() function to the table with the lowest granularity, here the Product table: 

                           - To the Product table, add a column that uses ProductSubcategory =                             RELATED(ProductSubcategory[ProductSubcategoryName])

                          - To the Product table, add a column that uses ProductCategory = RELATED(ProductCategory[Product Category Name])

 

My question is :

 

will it work with creating measures as well? like below: 

                          - To the Product table, add a calculated measure that uses ProductSubcategory =                             RELATED(ProductSubcategory[ProductSubcategoryName])

                         - To the Product table, add a calculated measure that uses ProductCategory = RELATED(ProductCategory[Product Category Name])

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: hierarchy with measures??!!

Hi elahemeydani,

 

The RELATED function needs a row context; therefore, it can only be used in calculated column expression, where the current row context is unambiguous, or as a nested function in an expression that uses a table scanning function. A table scanning function, such as SUMX, gets the value of the current row value and then scans another table for instances of that value. 

 

So to use RELATED() in measures, you must nest it in a table scanning function.

 

Reference: https://msdn.microsoft.com/en-us/query-bi/dax/related-function-dax

 

Regards,

Jimmy Tao

View solution in original post

1 REPLY 1
Community Support Team
Community Support Team

Re: hierarchy with measures??!!

Hi elahemeydani,

 

The RELATED function needs a row context; therefore, it can only be used in calculated column expression, where the current row context is unambiguous, or as a nested function in an expression that uses a table scanning function. A table scanning function, such as SUMX, gets the value of the current row value and then scans another table for instances of that value. 

 

So to use RELATED() in measures, you must nest it in a table scanning function.

 

Reference: https://msdn.microsoft.com/en-us/query-bi/dax/related-function-dax

 

Regards,

Jimmy Tao

View solution in original post

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Users Online
Currently online: 47 members 957 guests
Please welcome our newest community members: