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.
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.
Solved! Go to Solution.
@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" )
@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...)
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
97 | |
97 | |
82 | |
75 | |
66 |
User | Count |
---|---|
126 | |
105 | |
103 | |
81 | |
72 |