Forum Discussion

ashmitp869's avatar
ashmitp869
Icon for Responsive Resident rankResponsive Resident
1 year ago
Solved

Date field - sorting ascending issues due to null ?

Hi,

My date field is not sorting ascending as I got null.



Expected result - 

 

  • Hi ashmitp869 

    To handle the sorting in your table visual and ensure blank rows appear last while sorting dates in ascending order, 
    You can create a calculated column in your table that assigns a numeric value based on whether the date is blank or not. Here's an example DAX formula:

    Step 1 - Create a sorting column using dates
    SortOrder = IF(ISBLANK(Table[Date]), 1, 0)

    This creates a column sort order where

    • Blank dates get a value of 1
    • Non-blank dates get a value of 0

      Step 2 - configure sorting in power bi
    1. Go to the Fields pane and select your Date column.
    2. Set the sort by column as the newly created Sort Order.
    3. In your table visual, include the Date field as usual. The blank rows will appear last, and the non-blank rows will sort in ascending order.

      Best Regards
      Govind Sapkade ( Microsoft Certified Data Analyst , PL 300 Certified , MS Fabric Enthusiast)
      Let's Connect
      Linkdin - www.linkedin.com/in/govind-sapkade-845104225
      Youtube - http://www.youtube.com/@govind_dataanalyst

1 Reply

  • Hi ashmitp869 

    To handle the sorting in your table visual and ensure blank rows appear last while sorting dates in ascending order, 
    You can create a calculated column in your table that assigns a numeric value based on whether the date is blank or not. Here's an example DAX formula:

    Step 1 - Create a sorting column using dates
    SortOrder = IF(ISBLANK(Table[Date]), 1, 0)

    This creates a column sort order where

    • Blank dates get a value of 1
    • Non-blank dates get a value of 0

      Step 2 - configure sorting in power bi
    1. Go to the Fields pane and select your Date column.
    2. Set the sort by column as the newly created Sort Order.
    3. In your table visual, include the Date field as usual. The blank rows will appear last, and the non-blank rows will sort in ascending order.

      Best Regards
      Govind Sapkade ( Microsoft Certified Data Analyst , PL 300 Certified , MS Fabric Enthusiast)
      Let's Connect
      Linkdin - www.linkedin.com/in/govind-sapkade-845104225
      Youtube - http://www.youtube.com/@govind_dataanalyst