Forum Discussion

mdelasheras's avatar
mdelasheras
Helper I
8 years ago
Solved

Create custom Table from different sources

Hi all,

I'm trying to show a table with some calculations of different sources and I would like to know what's the best approach to achieve that. I will try to sum up as much as possible. 

The table I want to get is something like that:

USER_X

ConceptObjectiveWeightCurrent total% AchievedWeight 
Billing Area 10401638.20.25510221.370.2
Billing Area 20263342.160.151876770.710
Billing Area 30324437.640.153707851.140.15
Total Area 10150.2120.800
Total Area 20120.15131.080.15
Total Area 30100.15111.100.15
    Total weight0.65

 

My current model is:

Objectives_table:

Person_id : key
Year
Billing_10_obj

Billing_20_obj

Billing_30_obj

Billing_10_weight

Billing_20_weight

Billing_30_weight

Total_10_obj

Total_20_obj

Total_30_obj

Total_10_weight

Total_20_weight

Total_30_weight

 

Bills:
Person_id

Date

Area

Amount

 

Current total 10 = Sum of all bills amount from that person_id with area = 10

Total 10 = Count all bills from that person_id with area = 10

 

I will add some examples if the explanations isn't clear enough.

 

Thanks in advance!

5 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    mdelasheras,

    An idea is to unpivot columns in your Objectives_table, then merge the Objectives_table and Bills table. 

    In order for use to provide you detailed steps, please share sample data of your Objectives_table and Bills table, then post expected result based on the sample data.


    Regards,
    Lydia

    • mdelasheras's avatar
      mdelasheras
      Helper I

      Thanks Anonymous! I will add a detailed sample.


      Objectives_table:

      Person_idYearBilling_10_objBilling_20_objBilling_30_objBilling_10_weightBilling_20_weightBilling_30_weightTotal_10_objTotal_20_objTotal_30_objTotal_10_weightTotal_20_weightTotal_30_weight
      120183333002020001212100.50.10.18650.10.10.5
      2201814400080000500000.20.150.151230.20.150.15
      320182200002220002222000.60.40.33420.40.050.05

       

      Bills_table:

      Person_idDateAreaAmount
      109/01/201830684641
      118/04/20183046465
      214/03/20171044100
      227/02/20181089620
      218/04/20182047512
      218/04/20183015687
      229/03/20183051510
      322/01/20181014541
      316/04/20182054981

       

      Expected result for person_id = 2 and year = 2018:

      ConceptObjectiveWeightCurrent total% Achieved (current/obj)Weight reached*
      Billing Area 101440000.2896200.620
      Billing Area 20800000.15475120.590
      Billing Area 30500000.15671971.340.15
      Total Bills Area 1010.211.000.2
      Total Bills Area 2020.1510.500
      Total Bills Area 3030.1520.670
          Total weight0.35

       

      * Weight reached is 0 if % < 1, otherwise is weight


      Many thanks!