Ask Your Question
0

How can DAX RANKX be applied to two dimensional columns?

asked 2023-05-29 23:12:06 +0000

david gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-05-29 23:29:01 +0000

huitzilopochtli gravatar image

DAX RANKX function can be applied to two-dimensional columns using the CROSSJOIN function. The CROSSJOIN function combines two or more tables by creating all possible combinations of rows.

Here is an example of how to use DAX RANKX with two-dimensional columns:

Assume we have two tables, Sales and Products, and we want to rank the sales by product category and year.

  1. Create a measure to calculate the total sales for each category and year: Total Sales = SUM(Sales[Amount])
  2. Create a calculated table to crossjoin the Products table with the distinct years in the Sales table: YearTable = DISTINCT(Sales[Year]) CrossJoinTable = CROSSJOIN(Products, YearTable)
  3. Create a measure to calculate the total sales for each category and year combination: SalesByCategoryYear = CALCULATE( [Total Sales], CROSSFILTER(Sales[ProductId], Products[ProductId], Both), CROSSFILTER(Sales[Year], YearTable[Year], Both) )
  4. Create a measure to rank the sales by category and year: Rank = RANKX(CrossJoinTable, [SalesByCategoryYear])

This will give you a rank for each category and year combination in the CrossJoinTable. You can then use this rank in visualizations or to filter the data.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-05-29 23:12:06 +0000

Seen: 13 times

Last updated: May 29 '23