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!Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!
Hi All,
I am new to Dax and currently facing issues in defining variables.
Can we define table columns in Variable? Like I have a Table called Customer Master and I want to define a variable storing the customer ID. But the error is coming as Var is expecting a scalar value?
Kindly help!!
Solved! Go to Solution.
I think I got the solution of this issue. I was trying to write a measure instead of the calculated column.
Consider the following problem posted on this forum -
When I am trying to write this particular part of the code -
I think I got the solution of this issue. I was trying to write a measure instead of the calculated column.
You can work with columns in DAX but your measure has to return a scalar value. For example, in the dax below I'm storing a column in a variable but returning the sum of the column. If you reply with your specific use case, we may be able to help in more detail!
measure =
var sales = 'sales'[sales_amount]
return sum(sales)
Hi Syk, I build similar logic, but it doesn't work
@Syk wrote:You can work with columns in DAX but your measure has to return a scalar value. For example, in the dax below I'm storing a column in a variable but returning the sum of the column. If you reply with your specific use case, we may be able to help in more detail!
measure =
var sales = 'sales'[sales_amount]
return sum(sales)
Hi @rhinorocks ,
It depends on the logic and also on measure/column calculation you are trying to write using DAX.
Check this simple blog on variables:
https://www.purplefrogsystems.com/blog/2021/09/variables-in-dax/
Vote for your favorite vizzies from the Power BI World Championship submissions!
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 65 | |
| 49 | |
| 42 | |
| 25 | |
| 22 |
| User | Count |
|---|---|
| 143 | |
| 118 | |
| 56 | |
| 37 | |
| 31 |