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
Pick
Helper II
Helper II

create table with multiple rows with single dates to new table start and end dates

Hi,

 

I have a table below also with a time column.  I want to create a new table whch shows for every ID the two new columns showing the first Start data/time for that ID and one for the End date/time of the last status change.  I also want the table to have Order_no, Phase, Control strategy columns.

 

 Any help greatly appreciated.

 

Table.JPG

Thanks

1 ACCEPTED SOLUTION
v-lili6-msft
Community Support
Community Support

hi @Pick 

Just create a calculated table by this formula:

 

New Table = 
SUMMARIZE (
    'Table',
    'Table'[ID],
    'Table'[Order_No],
    'Table'[Phase],
    'Table'[CONTROL_STRATEGY],
    "Start date", CALCULATE (
        MIN ( 'Table'[Updated_At] ),
        FILTER ( ALL('Table'), 'Table'[ID] = EARLIER ( 'Table'[ID] ) )
    ),
    "End date", CALCULATE (
        MAX ( 'Table'[Updated_At] ),
        FILTER ( ALL('Table'), 'Table'[ID] = EARLIER ( 'Table'[ID] ) )
    )
)

 

 

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

3 REPLIES 3
v-lili6-msft
Community Support
Community Support

hi @Pick 

Just create a calculated table by this formula:

 

New Table = 
SUMMARIZE (
    'Table',
    'Table'[ID],
    'Table'[Order_No],
    'Table'[Phase],
    'Table'[CONTROL_STRATEGY],
    "Start date", CALCULATE (
        MIN ( 'Table'[Updated_At] ),
        FILTER ( ALL('Table'), 'Table'[ID] = EARLIER ( 'Table'[ID] ) )
    ),
    "End date", CALCULATE (
        MAX ( 'Table'[Updated_At] ),
        FILTER ( ALL('Table'), 'Table'[ID] = EARLIER ( 'Table'[ID] ) )
    )
)

 

 

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.

HI,

 

   Thanks for the reply it nearly worked.

  

   For each ID it is returning the earliest and latest status change.

 

  The Order_No is always unique.  Within every order number there are different IDs and different orders can have the same IDs.  So I need to get the earliest status and latest status for every ID within every order. 

 

The solution provided just searched for the earliest and latest ID status change independant of order_no we need this for every ID in every order.

 

  Thanks for your support

 

  Ian

ImkeF
Super User
Super User

Hi @Pick ,

 

in the query editor, group your table by "ID", choose the Minx and Maxes that your need and in addition to that, add a column with the aggregation "All". That will return the original rows by ID of the table and you can "expand back" all the other columns you need.

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

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.