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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
arifshah
Helper I
Helper I

Custom Sort in Power BI (by another column that is not unique per group)

Hi,

 

I have an interesting scenario. I need to sort line_item by a column named line_sort. However, this sorting changes for each line item according to the reportview column. For example, If the report view is Income Source, then the line_sort for closing balance line item is 16. However if the report view is income statement, then the line_sort for closing balance line item is 8.

 

When we visualize this data, we apply a filter to the visual based on the report view column (income statement, income source etc) so that each visual will have unique line items and line_sort. The line_sort should not be shown in the visual.

 

I am using Zebra BI and normal metrix and I could not find a way to sort the visual by a column that is not present in the visual.

 

an example of dummy data is below.

 

arifshah_0-1705311283005.png

 

The visuals will only show Amount by line items (sorted by line_sort but not shown in the visual). Each visual will be filtered by the reportview

 

 

One way for this to achieve was to use the feature where we click on the column line_item in the data property and in the "order by" feature, and selecting the "line_sort" column. Hower, since for the same line_item "closing balance", we have multiple line_sort (per report view, 8 and 16), this feature is not working for us and is throwing an error.

 

Can someone please guide me how to achieve this sorting for the line items?

2 REPLIES 2
Anonymous
Not applicable

Hi @arifshah

 

Based on your question, here's what I assume you might want to achieve:

 

Here's some dummy data

 

"Line item"

vnuocmsft_0-1705298346902.png

 

"Line sort"

vnuocmsft_1-1705298372471.png

 

If you want to sort line_item based on line_sort, try the following. Create a column,

vnuocmsft_3-1705298664216.png

line item sort = 
    LOOKUPVALUE(
        'Line sort'[line_sort], 
        'Line sort'[reportview], 
        'Line item'[reportview ]
    )

 

Select Zebra BI Tables, here is the result.

vnuocmsft_4-1705298842070.png

 

vnuocmsft_5-1705298922182.png

If you're still having problems, provide some dummy data and the desired outcome. It is best presented in the form of a table.

 

Regards,

Nono Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Hi,

 

Thank you for the reply and your solution. The scenario is a bit different for me. In my case, the line items are repeating and therefore, one line item may have multiple line_sorts. For example, take a look at the attached dummy data. Please note that at a time, the visual will be filtered by the reportview so that will not show multiple reportviews in the same visual. Can you please explain how would your solution work in this case?

 

arifshah_0-1705311365001.png

 

The visuals will only show Amount by line items (sorted by line_sort but not shown in the visual). Each visual will be filtered by the reportview

 

Helpful resources

Announcements
Top Kudoed Authors