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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
admin11
Memorable Member
Memorable Member

Problem Statement 3 on GL Analysis :- Sort P&L Field in Sequences

1 ACCEPTED SOLUTION

@admin11 

Download PBIX file

OK, because your table was created with DAX I had to modify this code to add the SortOrder column when the table was created

 

VAR tbl = {(t_rev, 1), (t_cogs, 2), (t_oth, 3) , (t_exp, 4)}

 

So now you can set the SortOrder in Model view for REV&COGS - I've already done it in the attached PBIX file.

sorto.png

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

7 REPLIES 7
PhilipTreacy
Super User
Super User

@admin11 

Hi Paul,

Sorry, slight modification here.

In Power Query create a new column called SortOrder in the table with this code

if [REV&COGS] = "REV" then 1 else if [REV&COGS] = "COGS" then 2 else if [REV&COGS] = "OTH" then 3 else 4

 

Which gives you this in the Data Model when you Close & Apply

sortord.png

 

Then in the Model view click on the REV&COGS column and set the Sort by Column to SortOrder

srtc.png

 

 

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


@PhilipTreacy 

thank you very much , i have add the expression for Sort , also set sort at model table , but the table still not yet sort.

Below my PBI file :-

https://www.dropbox.com/s/00v9fzpthv39v2u/PBT%20GL%20VER0030%20GL%20ANALYSIS%20PROBLEM%20STATEMENT%2...

 

I get error when i try to sort :-

admin11_0-1612498171608.png

 

Paul

 

@admin11 

Hi Paul,

Sorry I made a mistake in the initial answer. Check above for the correction.

regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Hi Phil

Very sorry , now i get more error.

admin11_0-1612500339789.png

 

Can you pls share with me the PBI file.

 

Paul Yeo

@admin11 

Download PBIX file

OK, because your table was created with DAX I had to modify this code to add the SortOrder column when the table was created

 

VAR tbl = {(t_rev, 1), (t_cogs, 2), (t_oth, 3) , (t_exp, 4)}

 

So now you can set the SortOrder in Model view for REV&COGS - I've already done it in the attached PBIX file.

sorto.png

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


@PhilipTreacy 

Thank you so much for your help, now it work fine now.

Paul

 

Anonymous
Not applicable

In power query, you can add an index column and then sort the visual.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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