Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hi Team,
I have a table that looks like the below (example). I'd like to filter by Item and then cost.
For example, i'd expect row 2 to be "A, TAS, 2, Three" and row 3 to be "A, QLD, 1, two" .
I have tried to sort in query editor mode, but when back in my table visual, it does not sort poperly. Any help is much appreciated.
Item | state | Cost | Supplier |
A | NSW | 4 | one |
A | QLD | 1 | two |
A | TAS | 2 | three |
B | NSW | 3 | one |
B | VIC | 4 | two |
C | NSW | 5 | one |
C | QLD | 4 | two |
C | TAS | 6 | three |
Solved! Go to Solution.
@Anonymous,
Table can be sorted by multiple columns, but I'm afraid this can only be achieved in power query. In power query, click advanced editor using M code like below:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUfILDgeSJkCcn5eqFKsDEQ30cQGShkBcUp4PFw1xDAaSRiDRjKJUiGonuBnGSGaARMM8naEmw8xwhqs1RVLrDLcPXS3EPjOEfbEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Item = _t, state = _t, Cost = _t, Supplier = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Item", type text}, {"state", type text}, {"Cost", Int64.Type}, {"Supplier", type text}}), Result = Table.Sort(#"Changed Type",{{"Item", Order.Ascending}, {"Cost", Order.Descending}}) in Result
Community Support Team _ Jimmy Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Anonymous,
Table can be sorted by multiple columns, but I'm afraid this can only be achieved in power query. In power query, click advanced editor using M code like below:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUfILDgeSJkCcn5eqFKsDEQ30cQGShkBcUp4PFw1xDAaSRiDRjKJUiGonuBnGSGaARMM8naEmw8xwhqs1RVLrDLcPXS3EPjOEfbEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Item = _t, state = _t, Cost = _t, Supplier = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Item", type text}, {"state", type text}, {"Cost", Int64.Type}, {"Supplier", type text}}), Result = Table.Sort(#"Changed Type",{{"Item", Order.Ascending}, {"Cost", Order.Descending}}) in Result
Community Support Team _ Jimmy Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
May I clarify that when you say power query do you mean query editor within PowerBI?
@Anonymous,
Yes, the code I've put is in query editor.
Community Support Team _ Jimmy Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
User | Count |
---|---|
84 | |
75 | |
69 | |
48 | |
39 |
User | Count |
---|---|
111 | |
56 | |
50 | |
42 | |
40 |