Forum Discussion

javedbh's avatar
javedbh
Helper II
10 years ago

sort data on date column

I want the data in a visualization sorted by date field. How can I achieve this?

 

X-axis will show Item Name, Y-axis will show Total Parts. But the items should be sorted by "Date Added" column.

 

Table structure:

Item Name, Total Parts, Date Added

 

Any help? Thanks.

3 Replies

  • austinsense's avatar
    austinsense
    Impactful Individual

    This took me a second to figure out what you're asking for - the only option for this currently is to go into the "Data" section in Power BI and use the "Sort by Column" feature - this will sort one column by the results in another column.

     

     

    • javedbh's avatar
      javedbh
      Helper II

      Here is my data:

      Item NamePass DiesTotal DiesDate Added
      Item A507028-Jan-16
      Item A709012-Feb-16
      Item A11514515-Feb-16
      Item A23030027-Feb-16
      Item A185010-Mar-16
      Item A6710017-Mar-16
      Item B6815012-Feb-16
      Item B11920027-Feb-16
      Item B26840017-Mar-16
      Item B742100028-Mar-16
      Item C548028-Jan-16
      Item C7510012-Feb-16
      Item C12815028-Mar-16
      Item C347029-Mar-16
      Item C791008-Apr-16

       

      There are multiple dates for each item. So when I select "Item Name" column, click "Sort by Column" button and select "Date Added", it gives me following error:

       

      "We cannot sort the 'Item Name' column by 'Date Added'. You can't have more than one value in 'Date Added' for the same value in 'Item Name'. Choose a different column for sorting or update the data in 'Date Added'.

       

      So how can I possibly sort the items by 'Date Added', Any idea??

       

      Is it possible that a new column be added in the existing table that contains max date for each respective item and use this new column as the 'Sort By Column'?

       

      BTW how did you add Calendar table in your example?

      • austinsense's avatar
        austinsense
        Impactful Individual

        Alright yes I see the issue.  Your comment about the Calendar table is very relevant.  You're data needs to be more "normalized"

         

        Email me and I'll send you a worked solution in Excel ([email protected]).  You need to break out the Items into a separate table and the dates into a separate table.