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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
arelf27
Helper II
Helper II

DAX Text Function - Change values of a text column (like a lookup table)

Hi. I have what seems like a simple scenario but I don't understand how to do this in DAX: 

 

I have a column on a table that has values (To Do, Next, WIP, Closed, etc.) - these values are multiple.. I need to write a measure to convert these as such: (1-To Do, 2-Next, 3-WIP, 4-Closed, etc.)     --I would have loved to do that by creating a lookup table or even just add and transform a column in Edit Queries, however I have a live connection to Visual Studio Team Services and thus most features are disabled, including Modeling, New Columns, Edit Queries, etc.. All I am able to do is Add a Measure (thus I'm trying to figure out how to do this in DAX..)  ---Essentially since I put this column on my X-axis, my sort order is not correct, hence I'm trying to rename values to get the correct sort order on the visual...

 

If I try to do If statement, etc. I keep getting multiple values were supplied to a function that was expecting a single value... 

 

In SQL this would be an equivalent of a simple Case statement, with a group by etc.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@arelf27, it sounds like you need to talk to the people in charge of your data and ask for a sort order column to be created.

 

Yes, a DAX calculated column could do this (there is a SWITCH() function that would work), but you confirmed that you can't create additional calculated columns.

 

In short, a measure won't work.  You can't put a measure on a categorical axis for a visual, Power BI won't let you.  The only visual that accepts measures on the axes like that is a scatter plot.

 

If you can create a calc column, try this:

 

SortMeasure =
SWITCH (
    SELECTEDVALUE ( Table[Column] ),
    "To Do", "1-To Do",
    "Next", "2-Next",
    "WIP", "3-WIP",
    "Closed", "4-Closed"
)

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

@arelf27, it sounds like you need to talk to the people in charge of your data and ask for a sort order column to be created.

 

Yes, a DAX calculated column could do this (there is a SWITCH() function that would work), but you confirmed that you can't create additional calculated columns.

 

In short, a measure won't work.  You can't put a measure on a categorical axis for a visual, Power BI won't let you.  The only visual that accepts measures on the axes like that is a scatter plot.

 

If you can create a calc column, try this:

 

SortMeasure =
SWITCH (
    SELECTEDVALUE ( Table[Column] ),
    "To Do", "1-To Do",
    "Next", "2-Next",
    "WIP", "3-WIP",
    "Closed", "4-Closed"
)

 

I see. Thaks for replying. I'm working with data from Visual Studio Team Services (VSTS) - built a solution in PowerBI Services by connecting to their app/content pack, so it's quite limiting as to what can be done.. I thought I'd try connecting live to it in PowerBI Desktop but with that the only additional thing I can do is create measures.. Everything else is still grayed out..  (basically I don't have access to this online Content Pack database...)

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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