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
Anonymous
Not applicable

Combine columns into one line for each order #

Hi, I am looking for help on how to combine all the process order status names for each OCP # into the same line. Using the latest transaction date. If anyone has any suggestions I would greatly appreciate it. 

 

a9c4vzz_0-1633720260918.png

 

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

Hi, @Anonymous ;

1.Please try it in power query (group by).

= Table.Group(#"Changed Type", {"OCP#"}, {{"Ship Date", each List.Max([Ship Date]), type nullable date}, {"TransactionDateTime", each List.Max([TransactionDateTime]), type nullable datetime}, {"a", each Text.Combine([ProcessOrderStatusName], ", "), type nullable text}})

The final output is shown below:

vyalanwumsft_3-1633916178122.png

 

2.If i understand error, you could try another like below:

vyalanwumsft_0-1633915500009.png

Here is M language.

 

= Table.Group(#"Changed Type", {"OCP#", "ProcessOrderStatusName"}, {{"Ship Date", each List.Max([Ship Date]), type nullable date}, {"TransactionDateTime", each List.Max([TransactionDateTime]), type nullable datetime}})

 

The final output is shown below:

vyalanwumsft_1-1633915658375.png

Best Regards,
Community Support Team_ Yalan Wu
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

4 REPLIES 4
v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ;

1.Please try it in power query (group by).

= Table.Group(#"Changed Type", {"OCP#"}, {{"Ship Date", each List.Max([Ship Date]), type nullable date}, {"TransactionDateTime", each List.Max([TransactionDateTime]), type nullable datetime}, {"a", each Text.Combine([ProcessOrderStatusName], ", "), type nullable text}})

The final output is shown below:

vyalanwumsft_3-1633916178122.png

 

2.If i understand error, you could try another like below:

vyalanwumsft_0-1633915500009.png

Here is M language.

 

= Table.Group(#"Changed Type", {"OCP#", "ProcessOrderStatusName"}, {{"Ship Date", each List.Max([Ship Date]), type nullable date}, {"TransactionDateTime", each List.Max([TransactionDateTime]), type nullable datetime}})

 

The final output is shown below:

vyalanwumsft_1-1633915658375.png

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Ashish_Mathur
Super User
Super User

Hi,

On a slightly larger datase, show the expected result.  I'd like to see what you specifically mean by the bold underlines portion - "Combine all the process order status names for each OCP # into the same line. Using the latest transaction date."?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
smpa01
Super User
Super User

@Anonymous  not entirely sure, what your requirement is, but if you have table like following

 

| ocp | datetime             | status | shipDate   | Index |
|-----|----------------------|--------|------------|-------|
| s1  | 1/1/2021 12:46:00 PM | a      | 2021-01-01 | 1     |
| s1  | 1/1/2021 1:46:00 PM  | b      | 2021-01-01 | 2     |
| s1  | 1/1/2021 2:46:00 PM  | c      | 2021-01-01 | 3     |
| s1  | 2/1/2021 2:46:00 PM  | d      | 2021-02-01 | 4     |
| s2  | 4/1/2021 12:46:00 PM | x      | 2021-04-01 | 5     |
| s2  | 5/1/2021 12:46:00 PM | y      | 2021-05-01 | 6     |
| s3  | 6/1/2021 12:46:00 PM | z      | 2021-06-01 | 7     |

 

and want an output like following

smpa01_0-1633723549470.png

then you need a measure like following

 

 

Measure =
VAR _0 =
    CALCULATE ( MAX ( 'Table'[shipDate] ), ALLEXCEPT ( 'Table', 'Table'[ocp] ) )
VAR _1 =
    CALCULATE (
        MAXX (
            FILTER (
                ADDCOLUMNS (
                    'Table',
                    "@concat",
                        CALCULATE (
                            CONCATENATEX ( 'Table', 'Table'[status], "," ),
                            ALLEXCEPT ( 'Table', 'Table'[ocp] )
                        )
                ),
                [shipDate] = _0
            ),
            [@concat]
        ),
        ALLEXCEPT ( 'Table', 'Table'[ocp] )
    )
RETURN
    _1

 

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
Anonymous
Not applicable

#"Grouped Rows" = Table.Group(Source, vDbo_vActiveOrderDashBoardDetails, {"ProcessOrderNbr"}, {{"Order Status", each Text.Combine([PhaseStatusValue],", "), type text}})
   
in
    #"Grouped Rows"

 

I tried this code but I am getting this error: 

 

a9c4vzz_0-1633722745158.png

 

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.