Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Need help to change the values in a matrix

Suvasini
7 - Meteor

Hi, I have a matrix similar to the table posted below. The first column are my origin stations and the first row is my destination stations. So while going from station A to B - there were 90 people. When I travel from station A to A, from B to B - it should be 0 and I was able to specify that. There is a 0 diagonal. Due to a requirement, all the numbers below the diagonal need to be zero too. So from station B to A, instead of 38 it should be 0 and likewise for all the cells below the diagonal. How can I do that?

 

 ABCDE
A090301755
B380981553
C527401713
D1005829078
E788469280
5 REPLIES 5
DavidP
17 - Castor
17 - Castor

Hi @Suvasini 

 

Would something like this work?

 

DavidP_0-1610006245757.png

 

Suvasini
7 - Meteor

Hi @DavidP (16 - Nebula)

Thank you for the quick response. Appreciate it, I tried the solution you sent, but the stations are headers itself so there is no F1,F2,F3 etc in my workflow. Also when there is a 0 value above the diagonal it doesn't seem to work as it makes all values below it zero. Would request your help again. I have attached a workflow with the data set close to what I'm working with. The idea remains the same that below the A-A, B-B diagonal (which is already 0), cells below it have to be zero too.

DavidP
17 - Castor
17 - Castor

Hi @Suvasini 

 

Let me know if this works for you and I can explain a little more of my methodology.

 

DavidP_0-1610012655209.png

 

Suvasini
7 - Meteor

Yes, this was the output needed. Thanks alot. Kindly explain the methdology.

DavidP
17 - Castor
17 - Castor

Excellent!

 

For my plan to work, it's important to preserve the row and column order, so I insert a Record ID and then use that to rename the columns with their relevant number. I can then use the Transpose tool to get all the values in a single column. I picked an arbitrary number of 0.000001 to assign the diagonal where Row ID = Column ID (or Origin = Original Column Name)

 

Using a sort tool, I can identify the rows below the diagonal for each column and then also set their value to 0.000001 with the multi-row formula tool (note that I use the group by functionality here)

 

Now I can re-sort the transposed rows before using the CrossTab tool to flip the data back to the original format.

 

Finally, I can restore the original column names with a Dynamic Rename tool.

 

Please let me know if you have any questions.

Labels
Top Solution Authors