Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Engine Works

Under the hood of Alteryx: tips, tricks and how-tos.
atcodedog05
22 - Nova
22 - Nova

by Kiran Manjunatha and Bhumika Agarwal (@BA02)


Once upon a time, before you read this awesome article:

 

Stakeholder: “Hey! Can you create merge cells column headers like we do in Excel? That would be super helpful.”

 

AlteryxMatt_0-1659563192836.png

 

Alteryx developer: I know how to merge row cells from Part 1. But merging columns is still a mystery to me.

 

After reading this article:

 

Alteryx developer: “Yes, it is possible! And I know how.”

 

Source: GIPHY

 

With the intention of not making this guide very long and boring at the beginning itself, here’s some good news! It will be a three-part series. Woohoo! Here is the outline of the series:

 

1. How to Create an Alteryx Report with Merged Rows

 

AlteryxMatt_2-1659563194535.png

 

2. How to Create an Alteryx Report with Merged Columns (you are here)

 

AlteryxMatt_3-1659563194571.png

 

3. How to Create an Alteryx Report with Both Merged Rows and Merged Columns

 

AlteryxMatt_4-1659563194662.png

 

Due to our lack of capability to generate cool datasets, we shall be using a subset of publicly available superstore sample data.

 

In this post, we will be covering part 2. If you missed part 1, click here to go to that blog.

 

Let’s get to it!

 

How to Create an Alteryx Report with Merged Columns

 

Prepare the data in the desired format with all the required columns you wish to see in your output. Refer to the example below.

 

AlteryxMatt_5-1659563194723.png

 

Now let's start by converting the data into the desired report first.

 

The concept here is that your merged cells column will become the parent table, and all the other columns will become columns in the child table.

 

Step 1: Filter child columns for each parent merge column header

 

Insert a Select tool and select the columns which you want to merge or keep un-merged, as depicted below:

 

AlteryxMatt_6-1659563194788.png 

Step 2: Create child tables for each parent merge row cell

 

Insert a Basic Table tool after Select tool with default configuration like below:

 

AlteryxMatt_7-1659563194815.png

 

Additionally, configure the tool to add the borders, background column, alignment, etc. [Optional]

 

Step 3: Create a method to pass the merge column header name

 

Create a Text Input tool with the column header name for each merged column header like below:

 

AlteryxMatt_8-1659563194838.png

 

Step 4: Create a merged cell header block

 

Insert a Basic Table tool and configure it like below:

 

AlteryxMatt_9-1659563194967.png

 

Additionally, configure the tool to add the borders, background column, alignment, etc. [Optional]

 

Step 5: Align the merged column table to the child table

 

Use a Union tool like below to place the merged cell table above the child table:

 

AlteryxMatt_10-1659563195064.png

 

This specific step will create merged column headers.

 

You can insert a Render tool and write to an Excel file to see the output. [Optional]

 

Step 6: Bring in all the sub-tables to create a single main table

 

Insert Join Multiple tools and join by record position like below.

 

AlteryxMatt_11-1659563195226.png

 

Insert a Layout tool with the default configuration to merge tables in separate columns into a single table like below. The current configuration behavior is to merge columns horizontally into one.

 

AlteryxMatt_12-1659563195291.png

 

Step 7 [Excel]: Phew! Output

 

Add a Render tool and configure it to write it to Excel.

 

AlteryxMatt_13-1659563195448.png

 

Excel report output:

 

AlteryxMatt_14-1659563195484.png

 

Other Formats

 

“We don’t want it in Excel. Any other formats which Alteryx can render to?”

 

For output formats other than Excel, we need to add an extra step to get the borders to align. Add a Layout tool and configure it as below:

 

AlteryxMatt_15-1659563195618.png

 

After the Layout tool, add a Render tool and configure it to the required file format. This table format after the Layout tool can also be used in the body section of an Email tool!

 

Optional Step [Other Formats]

 

You might have observed by now in formats other than Excel you can see the extra line like the one below Same Day row.

 

AlteryxMatt_16-1659563195719.png

 

You can make the extra lines less visible by using white borders and light gray background for the table cells like below. This will give a more elegant look. Nice!

 

AlteryxMatt_17-1659563195738.png

 

We hope this was helpful.

 

We highly encourage you to go and experiment so that you can better understand why we are following this approach.

 

Feel free to reply to this post and hit us up with your queries if you are facing any issues or need any clarifications. We shall be happy to help.

 

Cheers and Happy Analyzing :-)

 

Source: GIPHY

 

Stay tuned for the next part of this blog! We hope you’re as excited as we are for this blog series!

 

Read Part 3 Here.

Comments
mceleavey
17 - Castor
17 - Castor

@atcodedog05  you forgot step one: Tell them to stop reporting in Excel.

atcodedog05
22 - Nova
22 - Nova

@mceleavey good one 🤣🤣🤣

AsmiDesai
9 - Comet


@atcodedog05  @BA02 
Bookmarked this.. Definitely gonna need it..!! 🤓 

binuacs
20 - Arcturus

Nice work @atcodedog05 !!!!!

FH-toyo
6 - Meteoroid

@atcodedog05  @BA02 
Bookmarked this..Nice work!

 

DawnDuong
13 - Pulsar
13 - Pulsar

Wow this is cool, you really put a lot of time and efforts to this. Thank you!

Mond
8 - Asteroid

I am having trouble with this - for some reason the blank header columns are not being properly merged, there's leak of the other columns into the formatting. I am using version 2020.4 is that why? 

 

here's my selection:

Mond_0-1667838076780.png

 

here's the output i'm getting:

 

As you can see the R, bm, and Alph are showing up for some reason? Also the headers are getting cut off for ex. R should be Ret. 

 

Mond_1-1667838207923.png

 

Please let me know if i should be doing something else?

 

 

atcodedog05
22 - Nova
22 - Nova

Hi @Mond 

 

can you attach your workflow and the expected output. I will take a look into it.

Mond
8 - Asteroid

@atcodedog05 i'm unable to attach the .yxmd file to my comment. (it's giving me an error)

 

here's the output i'm expecting

Mond_0-1667939251794.png

 

 

and here's the output i'm getting

Mond_1-1667939416007.png

 

 

the only thing i changed vs the workflow you have above is the input data nothing else was touched

 

here's the data i'm using for the input

 

acctidbmName3m_Ret3m_Bmk3m_Alpha3m_Alloc3m_Selec3m_From3m_To12m_Ret12m_Bmk12m_Alpha12m_Alloc12m_Selec12m_From12m_To
123FTSE All-Share Index Net Return in GBP8.23E-04-7.93E-030.008818592-0.0018799770.010718727/1/20229/30/2022-0.116206395-3.74E-02-0.08188278-0.000596582-0.08133472210/1/20219/30/2022
456Bloomberg Global Aggregate-3.41E-02-4.52E-020.011608687-0.0042568170.0159333297/1/20229/30/2022-0.155674374-0.1659310230.0122971230.0066388650.00562094210/1/20219/30/2022
789MSCI EM (EMERGING MARKETS) -3.33E-02-4.90E-020.016601806-0.0080400450.0248415787/1/20229/30/2022-0.154862857-0.1663079880.0137282480.0027099070.01098856310/1/20219/30/2022
1012Bloomberg 1-3 Yr Gov/Credit Total Return-2.52E-02-3.10E-020.0060098330.0018521290.0041500187/1/20229/30/2022-0.134165962-0.135808740.0019009430.014970619-0.01287690110/1/20219/30/2022

 

atcodedog05
22 - Nova
22 - Nova

Hi @Mond 

 

This post might be helpful https://community.alteryx.com/t5/Alteryx-Designer-Discussions/RE-How-to-Create-Merged-Cells-in-Repor...

 

I guess there are a few bugs and I need to publish the revised version of the blog 😅

 

If you are still facing the same issue can you please start a new question on the discussion board (Homepage) and tag me? I will be able to attach the solution workflow there.

 

Happy to help : )

Mond
8 - Asteroid

@atcodedog05 that solution worked for me! you might want to update the blog here for this happening so it's good for next folks down the line :)     thanks again!

atcodedog05
22 - Nova
22 - Nova

Hi @Mond 

 

Thanks for confirming the solution worked. I will update the post soon as possible 🙂