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
Asaad_AlSharif
New Member

Semantic Model Data Source in Power bi is not getting the "Sort by column" in the Model View

I try to sort the month name by the number of the month inside the semantic model but its not reflacting in my power bi report??

 

Asaad_AlSharif_0-1727160678995.pngAsaad_AlSharif_1-1727160724039.png

 

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Hi @Asaad_AlSharif ,

 

Regarding the inconsistency of the “Sort By Column” display on the service side and the desktop side, I understand your problem and have tested it:

 

Here is my test data:

vhuijieymsft_0-1727248497923.png

 

I can reproduce your problem, in service I set the MonthName column to be sorted according to MonthNo, but after connecting this semantic model in desktop, I can see that it is not displayed according to my setting.

vhuijieymsft_1-1727248522095.png

vhuijieymsft_2-1727248522099.png

 

In power bi desktop, when connecting to the semantic model of the service, although sort by column shows incorrectly, when I use it in the visual object, it sorts by the sort field I set in the service. So I think it's a display issue that doesn't affect normal work.

 

When I choose to sort by MothName, if I don't set sort by column in service, it should sort alphabetically. However, since sort by MonthNo column is set in service, when I select sort by MonthName ascending in the visual object, I can see that the month names on the X-axis are sorted correctly.

vhuijieymsft_4-1727248533603.png

 

Please test it in your Power BI Dektop and see if it works fine as I did.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

View solution in original post

Asaad_AlSharif
New Member

Thank you for your detailed response and efforts, Yang.

I appreciate the tests you've conducted, and I understand the display issue on the Power BI Desktop when linked to the semantic model from the service. However, I've noticed that when using a Slicer, the sorting doesn't work as intended, even though it functioned correctly in earlier versions of Power BI.

To work around this, I am currently prefixing the month names with their respective numbers (e.g., "01-January", "02-February"). This method ensures the slicer sorts the months correctly. I thought it might be useful to mention this workaround in case others face a similar issue and are looking for a temporary solution.

 

from pyspark.sql import SparkSession
from pyspark.sql.functions import format_string, udf, concat_ws, date_format,col, trim, substring_index, regexp_replace,regexp_extract, when, expr, ltrim, rtrim, date_format, dayofmonth, weekofyear, month, quarter, year
from pyspark.sql.types import StringType

def translate_month(month_number):
    months_in_arabic = {
        1: "January", 2: "February", 3: "March", 4: "April",
        5: "May", 6: "June", 7: "July", 8: "August",
        9: "September", 10: "October", 11: "November", 12: "December"
    }
    return months_in_arabic.get(month_number, "")

month_udf = udf(translate_month, StringType())

# Define transformations
df_new_cases = df_cases.select(
concat_ws(" ", format_string("%02d", month("date_opened")), month_udf(month("date_opened"))).alias("MonthName"),,,,,,
)

 

 

Asaad_AlSharif_0-1727324267111.png

Best regards, Asaad AlSharif

View solution in original post

2 REPLIES 2
Asaad_AlSharif
New Member

Thank you for your detailed response and efforts, Yang.

I appreciate the tests you've conducted, and I understand the display issue on the Power BI Desktop when linked to the semantic model from the service. However, I've noticed that when using a Slicer, the sorting doesn't work as intended, even though it functioned correctly in earlier versions of Power BI.

To work around this, I am currently prefixing the month names with their respective numbers (e.g., "01-January", "02-February"). This method ensures the slicer sorts the months correctly. I thought it might be useful to mention this workaround in case others face a similar issue and are looking for a temporary solution.

 

from pyspark.sql import SparkSession
from pyspark.sql.functions import format_string, udf, concat_ws, date_format,col, trim, substring_index, regexp_replace,regexp_extract, when, expr, ltrim, rtrim, date_format, dayofmonth, weekofyear, month, quarter, year
from pyspark.sql.types import StringType

def translate_month(month_number):
    months_in_arabic = {
        1: "January", 2: "February", 3: "March", 4: "April",
        5: "May", 6: "June", 7: "July", 8: "August",
        9: "September", 10: "October", 11: "November", 12: "December"
    }
    return months_in_arabic.get(month_number, "")

month_udf = udf(translate_month, StringType())

# Define transformations
df_new_cases = df_cases.select(
concat_ws(" ", format_string("%02d", month("date_opened")), month_udf(month("date_opened"))).alias("MonthName"),,,,,,
)

 

 

Asaad_AlSharif_0-1727324267111.png

Best regards, Asaad AlSharif

Anonymous
Not applicable

Hi @Asaad_AlSharif ,

 

Regarding the inconsistency of the “Sort By Column” display on the service side and the desktop side, I understand your problem and have tested it:

 

Here is my test data:

vhuijieymsft_0-1727248497923.png

 

I can reproduce your problem, in service I set the MonthName column to be sorted according to MonthNo, but after connecting this semantic model in desktop, I can see that it is not displayed according to my setting.

vhuijieymsft_1-1727248522095.png

vhuijieymsft_2-1727248522099.png

 

In power bi desktop, when connecting to the semantic model of the service, although sort by column shows incorrectly, when I use it in the visual object, it sorts by the sort field I set in the service. So I think it's a display issue that doesn't affect normal work.

 

When I choose to sort by MothName, if I don't set sort by column in service, it should sort alphabetically. However, since sort by MonthNo column is set in service, when I select sort by MonthName ascending in the visual object, I can see that the month names on the X-axis are sorted correctly.

vhuijieymsft_4-1727248533603.png

 

Please test it in your Power BI Dektop and see if it works fine as I did.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June FBC25 Carousel

Fabric Monthly Update - June 2025

Check out the June 2025 Fabric update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors