Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Free Trial

Alteryx Designer Desktop Discussions

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

Multiplying 3 tables to build Profit and Loss Statement

anamik72
8 - Asteroid

I am a beginner and could use your help to build a workflow. Thank you so much in advance.

 

I am given following three input tables:

 

Table 1 - Amount by Customer by State by Month

Table 1 - Amount Table  
Cust IDStateJanFebMar
2GA101525
2CA202535
2NY303545
4CA253040
4GA152030

 

Table 2 - Weights table. This table need to multiply with Table 1 (joining by State)

Table 2 - Weight Table  
 StateJanFebMar
 GA          0.80          0.70          0.50
 CA          0.70          0.60          0.40
 NY          0.60          0.50          0.30

 

 

Table 3 - Rates table (for price and cost)

Table 3 - Rates Table
Cust IDRevenueCost
1          10.0            3.0
2            6.0            2.0
3            8.0            1.0
4            7.0            5.0
5            4.0            5.0

 

Here is the output table:

Intermediate step - multiple table 1 and table 2

Output by multiplying Table 1 and 2 (Join by State)
Cust IDStateJanFebMar
2GA8.0010.5012.50
2CA14.0015.0014.00
2NY18.0017.5013.50
4CA17.5018.0016.00
4GA12.0014.0015.00

 

Here is final output table by applying rates:

Final Output Needed    
LineCust IDStateJanFebMar
Revenue2GA       48.00       63.00       75.00
Revenue2CA       84.00       90.00       84.00
Revenue2NY     108.00     105.00       81.00
Revenue4CA     122.50     126.00     112.00
Revenue4GA       84.00       98.00     105.00
Cost2GA       16.00       21.00       25.00
Cost2CA       28.00       30.00       28.00
Cost2NY       36.00       35.00       27.00
Cost4CA       87.50       90.00       80.00
Cost4GA       60.00       70.00       75.00
Profit2GA       32.00       42.00       50.00
Profit2CA       56.00       60.00       56.00
Profit2NY       72.00       70.00       54.00
Profit4CA       35.00       36.00       32.00
Profit4GA       24.00       28.00       30.00
4 REPLIES 4
grossal
15 - Aurora
15 - Aurora

Hi @anamik72,

 

I think I got it:

 

grossal_0-1586551131868.png

 

Output: 

grossal_1-1586551156978.png

 

Values seem to be right from what I checked. It's not sorted to exactly match your table yet.

 

 

What happens:

1) I Shift all the columns (besides Key-Columns) to rows for easier Join

2) I calculate the Profit right at the beginning with an additional column

3) Join everything based on key + month 

4) Calculate everything (only one formula needed)

5) Shift everything back

6) Order the columns

7) Sort by Line

 

Workflow attached. Let me know what you think.

 

Best

Alex

 

JosephSerpis
17 - Castor
17 - Castor

Hi @anamik72 I mocked up a workflow and tried to design so it's dynamic as possible so can handle more months and will sort automatically in order. Let me know what you think?

 

10042020.JPG 

anamik72
8 - Asteroid

Thank you so much. This took care of it. And I found it very easy to follow. I can now scale it for entire dataset. Much appreciated.

anamik72
8 - Asteroid

Thank you Alex. Yes, I follow your logic and it takes care of my issue. Thanks again for helping me out. And for being so prompt.

Labels
Top Solution Authors