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.
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.
- PoojaReddy10 months agoRegular Visitor
Hi V-yubandi-msft,
No I havent received a proper solution. The issue still persists.
Any help would be appreciated.
- V-yubandi-msft10 months ago
Community Support
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.- V-yubandi-msft10 months ago
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 you need any further assistance.
Thank you.