Forum Discussion
Sorting applied in Power BI model is not getting applied in excel when connected to that model
- 10 months ago
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:In Excel :
Please let me know if any adjustments are needed. Thank you for your patience.
Regards,
Yugandhar.
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.