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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
MouserMike
Helper I
Helper I

Sort report by name then date

 I created a report to be used with Project Online that includes resource names and task assignments.  I want to sort the report first by the name, then the task (assignment) start date.  I've read several different posts about how to setup sorting based on two columns; below is the closest solution I've been able to find, created as a Measure and added to a Table visual:

Sort = 
VAR t =
    SUMMARIZE (
        ALLSELECTED ( Assignments ),
        Assignments[ResourceName],
        Assignments[AssignmentStartDate]
    )
RETURN
    COUNTROWS (
        FILTER (
            t,
            ISONORAFTER (
                    Assignments[ResourceName], SELECTEDVALUE ( Assignments[ResourceName] ), DESC,
                    Assignments[AssignmentStartDate], SELECTEDVALUE ( Assignments[AssignmentStartDate] ), DESC
            )
        )
    )

This works in that it doesn't generate any errors and does provides a value I can sort by and get the result I want.  However,  it takes an extremely long time for the report to open/refresh when working with the PBIX file (as in 5+ minutes) and this happens anytime I make a change to the visual displaying this data.  It also takes several minutes for the report to open when viewing on-line, and it's so bad it's unusable. 

 

I tried using the same formula as a custom column in the Advance Query Editor, thinking that might have better performance.  However, the syntax seems to be wrong for that scenario, and I'm not familiar enough the differences between measures and columns to troubleshoot it.

 

Any thoughts on a better way to sort this report by Name then Start Date?  Alternatively, any thoughts on how to increase the performance to an acceptable level?

1 ACCEPTED SOLUTION

hi, @MouserMike 

First, you should know that Difference between custom column and calculated column, please refer to this post:

https://community.powerbi.com/t5/Desktop/Difference-between-custom-column-and-calculated-column/td-p...

 

Second, from your formula we could know that this is a calculated column.

so you could add FORMAT Function in your formula to change the format to output.

New Sort = Assignments[ResourceName] & FORMAT ( Assignments[AssignmentStartDate].[Date], "yyyy/mm/dd" )

Result:

1.JPG

 

Best Regards,

lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
amitchandak
Super User
Super User

Can you try by creating a new column 

Concat Name and Date in YYYYMMDD format and try using it as the sort column

I created this column:

Sort = Assignments[ResourceName]&Assignments[AssignmentStartDate].[Date]

It defaults to a date format of mm/dd/yyyy so it doesn't sort correctly.  How do you specify a different format as part of the concatenation?

 

hi, @MouserMike 

First, you should know that Difference between custom column and calculated column, please refer to this post:

https://community.powerbi.com/t5/Desktop/Difference-between-custom-column-and-calculated-column/td-p...

 

Second, from your formula we could know that this is a calculated column.

so you could add FORMAT Function in your formula to change the format to output.

New Sort = Assignments[ResourceName] & FORMAT ( Assignments[AssignmentStartDate].[Date], "yyyy/mm/dd" )

Result:

1.JPG

 

Best Regards,

lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

I have the sorting working correctly using the calculated column in the visual:

New Sort = Assignments[ResourceName] & FORMAT ( Assignments[AssignmentStartDate].[Date], "yyyy/mm/dd" )

However, I really don't want this column to be visible in the visual; the individual columns are already there, and this calculated column looks rather weird since it's multiple columns concatenated together.  I've looked for ways to sort a visual by a column that is not part of the visual, but the only "solution" I've found is to add this calculated column to the far right of the visual, then shrink the width so it's almost invisible.  Is there another way to do this?

Instead of .date use .year and the same manner take month and date and append them. Also, check DateTime.ToText

If above did not help? let me know.

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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