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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
YIAX
Frequent Visitor

Sort Multiple Parent Rows with Children Rows

I am wanting to sort a table that contains multiple parent rows and children along with them using a dax measurement.

I am wanting to sort something like this in a table visual.

I am wanting to create the column SORT to actually sort my rows with parent and children. Parent Item would be 2.1 and its child would be 2.11 and so on. But not sure how to do that.

ITEM_IDPARENT_IDSORTIsParent 
AA 2.1TRUEPARENT
A0AA2.11FALSECHILD
A1AA2.11FALSECHILD
A2AA2.11FALSECHILD
AB 2.2TRUEPARENT
A3AB2.21FALSECHILD
AC 2.3TRUEPARENT
A4AC2.31FALSECHILD
3 REPLIES 3
v-yilong-msft
Community Support
Community Support

Hi @YIAX ,

As Ibendlin said , depending on your example you can choose to use Matrix. in Matrix if you don't make a fine distinction between subcolumns it will make them aggregate.

 

So I create a table as you mentioned.

vyilongmsft_0-1727662637495.png

Then I create two calculated columns.

 

SortOrder =
VAR _ParentSort =
    IF (
        ISBLANK ( 'Table'[PARENT_ID] ),
        'Table'[SORT],
        LOOKUPVALUE ( 'Table'[SORT], 'Table'[ITEM_ID], 'Table'[PARENT_ID] )
    )
RETURN
    _ParentSort & "_" & 'Table'[SORT] & "_" & 'Table'[ITEM_ID]
Column = IF('Table'[IsParent]="TRUE",'Table'[ITEM_ID] ,'Table'[PARENT_ID])

 

vyilongmsft_1-1727662786059.png

Next we can put them into the Matrix visual.

vyilongmsft_2-1727662890020.png

vyilongmsft_3-1727662911570.png

 

 

 

Best Regards

Yilong Zhou

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

In your solution, the sort column already exists. I am trying to create the sort column in this scenario. Then will display my data in a regular table visual not a matrix.

lbendlin
Super User
Super User

You can't sort AA, A1 and A2 all the same. At a minimum use 2.11, 2.11.1 and 2.11.2

 

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.