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!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
SELECTEDVALUE's first input is a column name but there is no way to input a column that belongs to a variable.
e.g.
VAR _table = CALCULATETABLE( VALUES ([col1]))
VAR _test = SELECTEDVALUE (_table[col1]) --incorrect syntax.
I understsand that there is a quirk with DAX where variable tables can only be referenced within iterator functions (or is this by design?) but does anyone know of a way to use SELECTEDVALUE in this situation?
My workaround is a bit clunky:
VAR _test = IF ( COUNTROWS (_table1) = 1, CONCATENATEX (_table[col1)))
Solved! Go to Solution.
@Anonymous wrote:The meaning of CALCULATETABLE(VALUES...) is quite straight forward no? I am retrieving a single column of distinct values using the current row context (this is a calculated column).
> Yeah, you did make me smile 🙂 First of all, you're not talking in your description clearly about a calculated column so people will think you're talking about a measure just as I did. What's more, you're describing it in such a way that it immediately tells an experienced developer it's about a measure. Please get your DAX vocabulary right.
Any my reference to _table1[col] is also correct since this is how I use it in the CONCATENATEX function (which is an iterator).
> I assure you that if you have a variable that stores a table in it, you CANNOT refer to the columns by using the variable's name but by using the name of the table that the column belongs to. Any experienced DAX dev will tell you that. I tell you that because I've tested these things years ago. I've been in this DAX business more than 6 years now doing a hard-core DAX development for quite a few global companies.
Your point on referencing variable tables in a filter modifier is irrelevant. I am talking about referencing columns in the table not the table itself. Basically read this Solved: DAX: Is it possible to refer to columns of a table... - Microsoft Power BI Community
> I've seen this article and in no place does it say that one can refer to a column in a variable using this INCORRECT syntax: VariableName[Column]. Because it's simply incorrect. You really should read things more carefully.
I don't think you've answered my question at all but I'll wait for someone who understands DAX better to respond
> I don't think anyone will answer your question and there are many reasons for that but I don't want to enlarge upon it. As for DAX understanding.... Well, you're arguing with one of the most accomplished DAX devs in the world so it's really hilarious :)))
Have a good day! 🙂
And what is the meaning of CALCULATETABLE( VALUES( [col1] ) )? Do you actually know when to use CALCULATE/CALCULATETABLE? And it's not true, of course, that tables stored in variables can only be used in iterators. They can be used in many more places. For instance, they can be filters to CALCULATE/CALCULATETABLE if they retain the so-called data lineage. SELECTEDVALUE is a function that returns the one value visible in the current context in a base table - that's what it's been designed to do and it does it well. There's no "quirk in DAX" contrary to what you think. The presented code is, well, bad but what you should do depends on many factors which you have not stated in your description, so I can't give you advice. If a variable has just one column and this column has just one value, then the table is automatically converted into a scalar value by DAX itself. To check if a table held in a variable has one row, you can count its rows (as you do above). If there is one row, then you can use the variable itself (if there's only one column). If there are more columns and you need the value from one of them, you can use the MAXX or MINX function. By the way, you can't reference a column in a variable called "_table" like _table[col1]. This will not work. How you address the column depends on how you obtained the variable in the first place...
The meaning of CALCULATETABLE(VALUES...) is quite straight forward no? I am retrieving a single column of distinct values using the current row context (this is a calculated column).
Any my reference to _table1[col] is also correct since this is how I use it in the CONCATENATEX function (which is an iterator).
Your point on referencing variable tables in a filter modifier is irrelevant. I am talking about referencing columns in the table not the table itself. Basically read this Solved: DAX: Is it possible to refer to columns of a table... - Microsoft Power BI Community
I don't think you've answered my question at all but I'll wait for someone who understands DAX better to respond.
Thanks
@Anonymous wrote:The meaning of CALCULATETABLE(VALUES...) is quite straight forward no? I am retrieving a single column of distinct values using the current row context (this is a calculated column).
> Yeah, you did make me smile 🙂 First of all, you're not talking in your description clearly about a calculated column so people will think you're talking about a measure just as I did. What's more, you're describing it in such a way that it immediately tells an experienced developer it's about a measure. Please get your DAX vocabulary right.
Any my reference to _table1[col] is also correct since this is how I use it in the CONCATENATEX function (which is an iterator).
> I assure you that if you have a variable that stores a table in it, you CANNOT refer to the columns by using the variable's name but by using the name of the table that the column belongs to. Any experienced DAX dev will tell you that. I tell you that because I've tested these things years ago. I've been in this DAX business more than 6 years now doing a hard-core DAX development for quite a few global companies.
Your point on referencing variable tables in a filter modifier is irrelevant. I am talking about referencing columns in the table not the table itself. Basically read this Solved: DAX: Is it possible to refer to columns of a table... - Microsoft Power BI Community
> I've seen this article and in no place does it say that one can refer to a column in a variable using this INCORRECT syntax: VariableName[Column]. Because it's simply incorrect. You really should read things more carefully.
I don't think you've answered my question at all but I'll wait for someone who understands DAX better to respond
> I don't think anyone will answer your question and there are many reasons for that but I don't want to enlarge upon it. As for DAX understanding.... Well, you're arguing with one of the most accomplished DAX devs in the world so it's really hilarious :)))
Have a good day! 🙂
It would still be valid even if in a measure 😉
VAR _test = IF ( COUNTROWS (_table1) = 1, CONCATENATEX (_table[col1)))
Try that code - see if it works. It does 🙂 So why are you saying _varTable[col] is incorrect syntax?
I don't want to argue but clearly you've not helped answer the question at all.
I assume SELECTEDVALUE cannot be used with a variable table column and my workaround is fine.
@Anonymous wrote:It would still be valid even if in a measure 😉
> Good programmers write good code. Bad programmers write bad, wordy and inefficient code and they always say: "But it works." Another thing that distinguishes good programmers from the bad ones. If that was a measure, there would be no need to wrap the function in CALCULATE. CALCULATE would be useless in there but people do it since they don't understand when to use CALCULATE.
VAR _test = IF ( COUNTROWS (_table1) = 1, CONCATENATEX (_table[col1)))
Try that code - see if it works. It does 🙂 So why are you saying _varTable[col] is incorrect syntax?
> You're wrong again. Here's a test:
First of all, CONCATENATEX does not take just on argument. Hence the error. But even if I make it right, you still can't do what you claim you can:
I don't want to argue but clearly you've not helped answer the question at all.
> I have helped you more than you might think.
I assume SELECTEDVALUE cannot be used with a variable table column and my workaround is fine.
> You don't have to assume. Just go to the documentation https://dax.guide/selectedvalue and you won't have to assume anymore. You'll just know.
Hint: Please do not argue with people who DO KNOW.
You're the only person who's arguing here (with yourself)?
"but does anyone know of a way to use SELECTEDVALUE in this situation?" - no.
Simple answer maybe next time keep it concise?
Nobody knows how to use SELECTEDVALUE in this situation because this function has been designed to solve a completely different problem, hence you've been trying to apply a wrong tool to the issue at hand. That's the short answer... but if I had written it like this, you wouldn't have had a chance to see what you've seen and learn from it. Your claims were false but you still wanted to convince me that I was wrong 😉 Always be careful who you're engaging with.
Have a good day! 🙂
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the September 2025 Power BI update to learn about new features.