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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
PoojaReddy
Regular Visitor

Sorting applied in Power BI model is not getting applied in excel when connected to that model

Hi,

I have a table with four hierarchical levels, and each level has its own sort column. When I apply sorting for each level in Power BI Desktop based on its corresponding sort column, it works correctly. However, when connecting Excel to the same Power BI model published to the service, the sorting doesn’t behave as expected — all blank values are getting grouped together.

Data :

PoojaReddy_0-1760208005774.png

Expectation :

PoojaReddy_1-1760208035719.png

In Excel :

PoojaReddy_2-1760208394529.png

 

Can anyone please help on this ?

 

Thank you !

 

8 REPLIES 8
V-yubandi-msft
Community Support
Community Support

Hi @PoojaReddy ,
Could you please let us know whether your issue has been resolved or if you are still encountering any difficulties? Your feedback is important to the community and may assist others with similar concerns.

Thank You.

V-yubandi-msft
Community Support
Community Support

Hi @PoojaReddy ,
May I know if your issue has been resolved, or if you still need any additional details? Please let us know if there’s anything else we can help with.

Thank you.

Hi @V-yubandi-msft,

No I havent received a proper solution. The issue still persists.

Any help would be appreciated.

Hi @PoojaReddy ,
In Power BI Desktop, sorting functions as expected, even when some hierarchy levels contain blank values, because Power BI follows the sort-by-column configuration. However, when connecting Excel to the same dataset using Analyze in Excel, Excel treats blank values differently. It groups all blanks together and does not maintain the defined sort order, which causes the hierarchy to appear incorrectly in Excel, even though it displays properly in Power BI.

 

To solve this issue, I added a new column that ensures each label is unique, including the blank ones. This allows Excel to recognize them as distinct entries and sort them properly.
DAX I used:

Level3_Cleaned = 
IF(
    ISBLANK([Level3]), 
    "~Blank (" & FORMAT([Sort1], "000") & ")", 
    [Level3] & " (" & FORMAT([Sort1], "000") & ")"
)

Once that’s in place.

1. Sort Level3_Cleaned by Sort1

2. Use  Level3_Cleaned  in your Excel PivotTable instead of the original Level 3.

I ran this with some dummy data and confirmed the logic works perfectly. Power BI and Excel now show consistent results, and the sort order is preserved across both platforms.
In PowerBI:

Vyubandimsft_0-1761319638980.png

In Excel :

Vyubandimsft_1-1761319717142.png

 

Please let me know if any adjustments are needed.  Thank you for your patience.

 

Regards,
Yugandhar.

 

 

Hi @PoojaReddy ,

May I know if your issue has been resolved, or if you still need any additional details? Please let us know if you need any further assistance.
 

Thank you.

PoojaReddy
Regular Visitor

Hi @Greg_Deckler,

Thank you for the response !

We use Tabular Editor to make changes in the model hence it is getting treated with a warning. 

Our concern is mainly on the excel. Even though we have same sort order number for blanks it doesnt work in excel.

This is a situation where Power BI Desktop and Excel handle things differently, even when working with the same model. When you use Tabular Editor to set the sort order, Power BI Desktop allows multiple blank values to have the same sort key, but Excel is stricter and groups all blanks together, ignoring the sort metadata.

 

You can try these options:

1. Replace blank values with placeholders like ~ or Undefined so Excel can tell them apart, and assign each a unique sort number.

2. Create a composite sort column, such as combining LevelName and SortOrder, and sort your display column by this new field to ensure uniqueness.

3. Check how Excel is applying the sort, especially if you’re using a Pivot Table, as it may use its own sorting logic in addition to the model’s sort order.

 

Regards,
Yugandhar.

Greg_Deckler
Community Champion
Community Champion

@PoojaReddy When you say "apply sorting for each level in Power BI Desktop based on its corresponding sort column" how are you doing that exactly? Because you can't define Sort by columns with the data that you have because you have multiple different sort values for blank values and that is not allowed.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.