Combining/Extract data from columns and row from merged to one column

Watever

New Member
Joined
Jun 6, 2024
Messages
3
Office Version
  1. 365
Platform
  1. Windows
May be there is another way to what I am trying to create, but it is getting me nuts trying to find how to do it.
I am verifying (for different products) if there is enough qty in stock of the same case pack as requested. If not, I need to show the user what other form pack is available.

I am merging two queries and I would like to combine two columns in one cell from the resulting merge.
I am able to merge one column by doing a list and a delimiter but not with 2 column.

What I want my table to output is

ProduitNbr Pal SelectTiHiTiHiAvailable
1598206594551 x 1
46 x 1
41 x 1
35 x 1
113 x 1
51 x 119
45 x 34

This is what my ordered product look after a merge.
Screenshot 2024-05-31 152209.png


And this is what inside my Rsv_EXT column of table.
Screenshot 2024-05-31 152943.png
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Welcome to the MrExcel Message Board!

See if the following will give the idea. The Source is just a sample data in the code.
Otherwise, please try to add your sample source data, current query, and the desired result by using XL2BB.

Power Query:
let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjS1tDAyUNJRMjUEEoZKsTpIYiZmWMSwqDM2xRQzNDTGFDQ1ActYohkJ0m5sghAEW2GAqh0kBlZthCpmjKbOCGQgmjqQmClUXSwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [article = _t, qty = _t, Count = _t]),
    GroupRows = Table.Group(Source, {"article"}, {{"Table", each _}}),

    Result = Table.TransformColumns(GroupRows, 
                {
                    "Table", 
                    each Lines.ToText(
                            Table.CombineColumns(_, {"qty", "Count"}, Combiner.CombineTextByDelimiter(" x "), "temp")[temp])
                }
            )
in
    Result

This is the query/data structure:
1717752770451.png

and the result (you need to set cells back in Excel as Word Wrap).
1717752785280.png
 
Upvote 0
Solution
Welcome to the MrExcel Message Board!

See if the following will give the idea. The Source is just a sample data in the code.
Otherwise, please try to add your sample source data, current query, and the desired result by using XL2BB.

Power Query:
let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjS1tDAyUNJRMjUEEoZKsTpIYiZmWMSwqDM2xRQzNDTGFDQ1ActYohkJ0m5sghAEW2GAqh0kBlZthCpmjKbOCGQgmjqQmClUXSwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [article = _t, qty = _t, Count = _t]),
    GroupRows = Table.Group(Source, {"article"}, {{"Table", each _}}),

    Result = Table.TransformColumns(GroupRows,
                {
                    "Table",
                    each Lines.ToText(
                            Table.CombineColumns(_, {"qty", "Count"}, Combiner.CombineTextByDelimiter(" x "), "temp")[temp])
                }
            )
in
    Result

This is the query/data structure:
View attachment 112416
and the result (you need to set cells back in Excel as Word Wrap).
View attachment 112417
This is perfect, it works wonderfuly. I didn't know about the "each lines to text" step.
I just had to convert my columns number to text in the other queries where I merged.
It didn't seem possible to do it inside the result step or in the merge.

But it works, thank you very much.
 
Upvote 0
You're welcome. Glad to hear it helps.

I think we can change the column types in the same query by using the Table.TransformColumnTypes function.
Power Query:
let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjS1tDAyUNJRMjUEEoZKsTpIYiZmWMSwqDM2xRQzNDTGFDQ1ActYohkJ0m5sghAEW2GAqh0kBlZthCpmjKbOCGQgmjqQmClUXSwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [article = _t, qty = _t, Count = _t]),
    PrepareData = Table.TransformColumnTypes(Source,{{"qty", Int64.Type}, {"Count", Int64.Type}}),
    GroupRows = Table.Group(PrepareData, {"article"}, {{"Table", each _}}),
    
    Result = Table.TransformColumns(GroupRows, 
                {
                    "Table", 
                    each Lines.ToText(
                            Table.CombineColumns(
                                Table.TransformColumnTypes(_,  {{"qty", type text}, {"Count", type text}}),
                                {"qty", "Count"},Combiner.CombineTextByDelimiter(" x "), "temp"
                            )[temp]   
                        )
                }
            )
in
    Result
 
Upvote 0
Hello, how do you obtain this data?

Hello, @veyselemre

Home tab -> Click Enter Data:
1717849055972.png

Enter data manually, or copy & paste from a range:
1717849137514.png


Click OK, it will create a new query with data you just entered:
1717849178574.png


Go to the Source step and copy it to use in another query, or directly keep working on the same query.
1717849224155.png


It is just a base-64 encoded string - compressed version of the manually entered data table. Then Binary functions are used to decompress it to be used in the query.
This is what we generally use to provide sample data with Power Query implementations.
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,150
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top