Forum Discussion
Slicer Sort Issue
- 10 years ago
SNik, your verbiage gives me pause as to how you applied the sort. I will err on the side of being overly explicit, as I am unable to reproduce the behavior you describe. When I set a Sort By attribute on a field in PBI Desktop, that sort order is respected in any slicer I create.
- Select [field2]
- With [field2] selected choose Sort By Column
- In drop-down menu that appears, place a check mark next to [Field1]
As I said, the specific verbiage you used gave me pause, and it sounded like you might be selecting [Field1] and applying a sort order to it.
Sort By Column is essentially saying "sort the currently selected field using the order defined by the associated values in another field."
It is not saying "apply the values of the selected field to another when sorting."
I hope I am being clear, and again I apologize if I'm only telling you things you already know. I just want to make sure we're performing the same steps and getting different results.
- Anonymous10 years ago
SNik Return a single value per combination. All "Under 1000" will = 1, all "[01 -2 K]" will = 2
row price pricebracket
1 1 Under 1000
2 1 Under 1000
3 1 Under 1000
4 1 Under 1000
5 2 [01 -2 K]
Hello!
I think this is what I am needing for my situation, but I need a little extra information for this newbie. :)
I have odometer readings for vehicles. (My dataset is all about vehicles -make, model, etc.)
What I want to do is create a slicer that will allow someone to see all vehicles with 0-10K odometer reading. Right now, someone would have to click every value under 10K to see that. (At least, from my perspective as I don't know another way.) It seems that this "M" language method is the best way to accomplish this.
If I am understanding correctly, I need to create another table like this:
Row Odometer Odometer Range
1 1 Under 10K
2 1 Under 10K
Where my confusion comes in is in the Odometer [Price] column. I don't understand why it is the same value over and over again. It seems that SNik understands why, but this newbie doesn't.
Can someone walk me through exactly how to do this? Where to go in Power BI Desktop and what to click, etc? Any and all help is greatly appreciated!
- Anonymous10 years agoNot applicable
Be There are a couple things at play here.
1) Your request is a little different, but could include the solutions described in this post. This thread is speaking about how to "order" a column by a different column. In your case, you may want to order your new group if it doesn't show up as expected. If that is the case, you would add the "price" column to be a distinct value that corresponds to each of your groups. 1= 0-10K, and each row would get a 1 for that group. The reason for this, is that each row needs the same 1 to 1 match in order to apply the "sort by column" function.
2) For the "how to group" question, you can do this during the data load in M code (as example above), but it may be easier in your case as a newbie to create this using a calculated column. This would be after you already loaded your data, you would use the DAX language to create an "IF" or "SWITCH" DAX function to check for and substitute the actual value for a group value in the calculated column.
Really rough example, right click on your table - "New Column", the DAX code bar will pop down and you can enter a calculation similiar to this.
= SWITCH(TRUE(),
AND([Odometer] >=0, [Odometer] <=10000), "0 to 10K"
AND([Odometer] >=10001, [Odometer] <=30000), "10 to 30K"
AND([Odometer] >=30001, [Odometer] <=60000), "30 to 60K"
"60K+")- Look up the specific syntax here to be sure, and just build out your groups as needed