Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
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 =
SELECTCOLUMNS(
    FILTER(
        'Table1',
        'Table1'[CustomerID] = 'Current Table'[CustomerID]
        && 'Table1'[Start Date] <= variable1
        && 'Table1'[End Date] > variable2
        && 'Table1'[Urgency] = variable3
    ),
    "Department",'Table1'[Department]
)

return
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!

1 REPLY 1
Greg_Deckler
Super User
Super User

Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.