Hi guys,
I want to rank the same number for each client based on business line as part of a dynamic dax measure.
I’ve worked out how to do it with a table created by a dax measure but when I do the same in a virtual table, incorrect results are returned. The tables on the right show correct results but the table on the left shows incorrect results, all rankings are number 2, regardless of business line:
My PBI working file is here, sheet “ranking test”
5 Hierarchy Bar Chart.pbix (312.3 KB)
The DAX for my calculated table is this, it returns correct results:
dim_Clients With Ranking =
VAR __tbl =
ADDCOLUMNS(
ALLSELECTED( dim_Contractors[Type of business line #1]),
"@amount",
[Revenue]
)
VAR __rank =
ADDCOLUMNS(
SUMMARIZE(
dim_Contractors,
dim_Contractors[Client name v2],
dim_Contractors[Type of business line #1]
),
"Ranking",
RANK(
DENSE,
__tbl,
ORDERBY( [@amount] , ASC , dim_Contractors[Type of business line #1], ASC)
)
)
RETURN
__rank
and then I just add a simple MIN and I create my visual with ranking based on business line:
MIN('dim_Clients With Ranking'[Ranking])
but when I do the exact same thing with a virtual table, incorrect results are returned:
VAR __tbl =
ADDCOLUMNS(
ALLSELECTED( dim_Contractors[Type of business line #1]),
"@amount",
[Revenue]
)
VAR __rank =
ADDCOLUMNS(
SUMMARIZE(
dim_Contractors,
dim_Contractors[Client name v2],
dim_Contractors[Type of business line #1]
),
"Ranking",
RANK(
DENSE,
__tbl,
ORDERBY( [@amount] , ASC , dim_Contractors[Type of business line #1], ASC)
)
)
VAR __minx =
MINX(
__rank,
[Ranking]
)
RETURN
__minx
Thanks,
Tim