Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi guys,
I'm trying to get a rank column in the same script I create a new table as follows, but reference inside filter to tmp1 is not accepted (tmp1 table not found). If I just return the table without the rank, and then add a new calculated column with the code below, it works fine. My question is, if there's a way to directly create the rank in the same script as table. Thanks to all!!
---------not working code--------
Solved! Go to Solution.
Hi @sersanch
You cannot use a variable name as a table reference. You can try by referring the column name only
aidsByDateCarts =
VAR tmp1 =
FILTER (
SUMMARIZE (
train,
train[events.type],
train[timest].[Date],
train[events.aid],
"numEvents", COUNT ( train[events.aid] )
),
train[events.type] = "carts"
)
VAR tmp2 =
ADDCOLUMNS (
tmp1,
"rank", RANKX ( FILTER ( tmp1, [Date] = EARLIER ( [Date] ) ), [numEvents] )
)
RETURN
tmp2
Hi @sersanch
You cannot use a variable name as a table reference. You can try by referring the column name only
aidsByDateCarts =
VAR tmp1 =
FILTER (
SUMMARIZE (
train,
train[events.type],
train[timest].[Date],
train[events.aid],
"numEvents", COUNT ( train[events.aid] )
),
train[events.type] = "carts"
)
VAR tmp2 =
ADDCOLUMNS (
tmp1,
"rank", RANKX ( FILTER ( tmp1, [Date] = EARLIER ( [Date] ) ), [numEvents] )
)
RETURN
tmp2
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 19 | |
| 13 | |
| 8 | |
| 4 | |
| 4 |
| User | Count |
|---|---|
| 29 | |
| 24 | |
| 17 | |
| 11 | |
| 10 |