Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more.
Get startedGrow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.
Hi All,
I would like to add a rank column for virtual table created by Dax function, my code as below
DEFINE
MEASURE Sales[sale_amount] = sumx(Sales, Sales[Quantity] * Sales[Net Price])
var temp = SUMMARIZECOLUMNS (
Customer[Country],
"Sales Amount1",Sales[sale_amount]
)
EVALUATE
ADDCOLUMNS(temp, "rankx",rankx(
Customer[Country],
Sales[sale_amount]
)
)
I got the error say "Table variable name 'temp' can not be used in the current context because a base table is expected" , this mean Rankx function can not work with virtual table created by Dax code ??
Dataset used in the lab from this link Introducing RANKX in DAX
Hi,
Please try something like below.
DEFINE
MEASURE Sales[sale_amount] =
SUMX ( Sales, Sales[Qualtity] * Sales[Net Price] )
VAR temp =
SUMMARIZECOLUMNS ( Customer[Country], "Sales Amount1", Sales[sale_amount] )
EVALUATE
ADDCOLUMNS (
temp,
"rankx", RANKX ( VALUES ( Customer[Country] ), Sales[sale_amount] )
)
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
hi @Jihwan_Kim ,
The code provided work as well, however could you please help clarify why we can not use the code below ?
"rankx", RANKX ( VALUES ( temp[Country] ), temp[Sales Amount1] )
User | Count |
---|---|
52 | |
46 | |
20 | |
16 | |
13 |
User | Count |
---|---|
108 | |
54 | |
31 | |
20 | |
18 |