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
JonHacking
Frequent Visitor

Sort by Columns On Unpivoted dataset

I have a table as below:

 

Consultant | Value A | Value B| Value C|....|Value Z|
Con 1         |           0 |           1|            3|...|           5|

I need a Table Visual Where you are able to add/remove Values Dynamically so have Unpivoted The 'Value' Columns To create the following dataset:

Consultant| Value Type|Value|
Con 1        | Value A     |       0|
Con 1        | Value B     |       1|
Con 1        |Value Z      |       5|

 

I've then built a matrix visual with Consultant as the row dimension, Value Type as the column dimension and Value as the Value dimension. I've then included Value Type as a Filter Visual so I can pick and Choose Columns.
However, this removes the ability to sort based on an individual column.

Is there any way to be able to choose columns dynamically whilst also being able to sort on individual columns?

Any help would be appreciated,

Thanks,

Jon

6 REPLIES 6
JonHacking
Frequent Visitor

Unfortunately no, it looks like it is not possible.

v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @JonHacking ,

I have a little confused about your requirement.

Is there any way to be able to choose columns dynamically whilst also being able to sort on individual columns?

What is the individual columns do your mean? Do you want to sort by column headers in matrix like below.

matrix.PNG

Actually, we cannot sort by column field in matrix directly in Power BI and the column is ordered by A-Z by default in matrix.

If you want to sort your columns in matrix, you could use Sort by Column under modeling tab in Power BI.

I made a sample which should be more obvious.

Assuming that you have the data like below and you want to create the matrix the unpivot data, then sort the column by month.

Capture.PNG

You need to add an index column after unpivot columns.

Then you need to sort month column by index column.

sort by column.png

Here is the output.

Untitled.png

Hope this can help you.

Best Regards,

Cherry

 

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-piga-msft ,

 

Apologies, I realize what I said before was a bit vague and am unsure how to upload images without an image hosting service. So will try my best to clarify below:

 

I have the report set up as per your first image, albeit with more than 1 constant (e.g. Con 1, Con 2, Con 3 etc.)

 

What I want to be able to do is keep the Attribute filter, whilst being able to sort by the SUM of one of the matrix columns.

 

e.g. From This:

 

Constant  | Value A   |  Value B  |  Value C  |
Con 1       |           3   |             0 |              0 |
Con 2       |           5   |             1 |              0 |
Con 3       |           4   |             2 |              1 |

To This:

 

Constant  | Value A ↓|  Value B  |  Value C  |
Con 2       |           5   |             1 |              0 |
Con 3       |           4   |             2 |              1 |
Con 1       |           3   |             0 |              0 |

 

Hopefully this makes sense,

Jon

Hi @JonHacking ,

By my tests, we cannot achieve your desired output directly in matrix, but we could create a measure to achieve that.

Measure = CALCULATE(MAX('Table2'[Value]))

Then you could drag the measure under Value Field to create the matrix like below and sort by measure. 

sort by.png

More details, please refer to my attachment.

Best Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you for your response, In your example, how would you then sort by Value B whilst keeping Value A in the Visual?

 

Thnaks Again

 

Jon

Did u get solution to this issue

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.