Showing results for 
Search instead for 
Did you mean: 
Not applicable

Using a column as a variable in a calculated column formula

Hi all,


I'm running into trouble trying to use SELECTEDVALUE on a column from a table variable.


See code below from calculated column, inside "Current Table"


Department Selected = 

//Other defined variables here...

var temptable =
        'Table1'[CustomerID] = 'Current Table'[CustomerID]
        && 'Table1'[Start Date] <= variable1
        && 'Table1'[End Date] > variable2
        && 'Table1'[Urgency] = variable3

SELECTEDVALUE('temptable'[Department], "multiple departments")


My code of course fails on the return, as you can't seem to reference a column of a variable table in selectedvalue.


Is there an alterative way I can accomplish this?

I don't want to use CALCULATE, as it takes absolutely ages and I'm trying to find a workaround. I also need it to be a calculated column, so can't use a measure.


Thanks in advance!

Super User
Super User

Please see this post regarding How to Get Your Question Answered Quickly:

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

MPPC 2023 PBI Carousel

Power Platform Conference-Power BI and Fabric Sessions

Join us Oct 1 - 6 in Las Vegas for the Microsoft Power Platform Conference.

Top Solution Authors