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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
vipin_jha123
Frequent Visitor

Sorting in Matrix report

Hi All,

 

I am new to Power BI Development. I have a simple requirment where I need to create a Matrix report.

Which I created like below which is fine.

vipin_jha123_0-1638184286103.png

but the one issue with above report is the highlighted filed required in a proper order.

1st should be PTD , then ELM and finally CIS .

To achive this I created one master table which hoold the code value in a proper order like below.

 

vipin_jha123_1-1638184400760.png

 

but this is also not helping.

 

Please do let me know which setting I am missing.

Thanks in advance.

 

Regards,

Vipin Jha

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @vipin_jha123 

 

Sort Code column by CodeId column in code table. Create a relationship between two tables on Code columns. Put Code column from code table into the matrix. Now it should be sorted as expected. You probably missed the first sort by step. See Sort one column by another column in Power BI Desktop - Power BI | Microsoft Docs

21120305.jpg

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

4 REPLIES 4
v-jingzhang
Community Support
Community Support

Hi @vipin_jha123 

 

Sort Code column by CodeId column in code table. Create a relationship between two tables on Code columns. Put Code column from code table into the matrix. Now it should be sorted as expected. You probably missed the first sort by step. See Sort one column by another column in Power BI Desktop - Power BI | Microsoft Docs

21120305.jpg

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

amitchandak
Super User
Super User

@vipin_jha123 , Have marked Codeid as he sort column for code ?

 

 

and is code is getting used from this Table ?


PowerBI Abstract Thesis Episode 6: How to Create Sort Column and Solve Related Errors:
https://www.youtube.com/watch?v=KK1zu4MBb-c

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi,

I am attaching below script for raw table.

/****** Object: Table [dbo].[rawdata] Script Date: 30-11-2021 12:22:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[rawdata](
[Due_Date] [varchar](100) NULL,
[ID] [bigint] NULL,
[Payment] [int] NULL,
[CODE] [nvarchar](10) NULL
) ON [PRIMARY]
GO
INSERT [dbo].[rawdata] ([Due_Date], [ID], [Payment], [CODE]) VALUES (N'01-10-2021', 56536, 63, N'CIS')
GO
INSERT [dbo].[rawdata] ([Due_Date], [ID], [Payment], [CODE]) VALUES (N'01-10-2021', 56536, 6, N'PTD')
GO
INSERT [dbo].[rawdata] ([Due_Date], [ID], [Payment], [CODE]) VALUES (N'01-10-2021', 56536, 87, N'ELM')
GO
INSERT [dbo].[rawdata] ([Due_Date], [ID], [Payment], [CODE]) VALUES (N'01-11-2021', 56536, 63, N'CIS')
GO
INSERT [dbo].[rawdata] ([Due_Date], [ID], [Payment], [CODE]) VALUES (N'01-11-2021', 56536, 6, N'PTD')
GO
INSERT [dbo].[rawdata] ([Due_Date], [ID], [Payment], [CODE]) VALUES (N'01-11-2021', 56536, 87, N'ELM')
GO
INSERT [dbo].[rawdata] ([Due_Date], [ID], [Payment], [CODE]) VALUES (N'01-10-2021', 56896, 63, N'CIS')
GO
INSERT [dbo].[rawdata] ([Due_Date], [ID], [Payment], [CODE]) VALUES (N'01-10-2021', 56896, 6, N'PTD')
GO
INSERT [dbo].[rawdata] ([Due_Date], [ID], [Payment], [CODE]) VALUES (N'01-10-2021', 56896, 87, N'ELM')
GO
INSERT [dbo].[rawdata] ([Due_Date], [ID], [Payment], [CODE]) VALUES (N'01-11-2021', 56896, 63, N'CIS')
GO
INSERT [dbo].[rawdata] ([Due_Date], [ID], [Payment], [CODE]) VALUES (N'01-11-2021', 56896, 6, N'PTD')
GO
INSERT [dbo].[rawdata] ([Due_Date], [ID], [Payment], [CODE]) VALUES (N'01-11-2021', 56896, 87, N'ELM')
GO

 

I am looking for report like below

vipin_jha123_0-1638255243159.png

 

highlighted column should come in correc order  like PTD , ELM and the CIS should come.

 

Thanks,

Vipin Jha

Yes This Code column I refered from Code table where I maintain the Codeid.

But when I am dragging this CodeId column in column I am not able to see it for sorting.

if you ok I am ok to share the report file.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.