Forum Discussion

TonySwad's avatar
TonySwad
Frequent Visitor
8 years ago

Dynamically Generate a Table from Information Distributed Across Data Structure

 

I have multiple tables in my data structure.

I need to auto generate a table that allocates volumes from the tblCtrMtrDetail table to the individual price indices to which the volumes have price exposure. The price indices to which each tblCtrMtrDetail record’s volume is exposed are determined from the price schedule associated with the contract and identified in the tblCtrAttributes file.  Each price schedule is a weighted average of various indices.  The weight for each index used in a price schedule is in tblSchedIndexDetail for which the primary key is Sched_id & index_id.

The generated table would ideally contain the following fields:

Ctr_Id, Mtr_Id, Prod Date, Price Schedule Id, Index Id, Index Proportion, Allocated Volume (calculated field)

4 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi TonySwad,

     

    You could create a table from Modelling tab using Distinct(tblCtrMtrDetai[Ctr_Id]), then using Lookup pull in all other columns. 

     

    Does this help?

    • TonySwad's avatar
      TonySwad
      Frequent Visitor

      Thank you for your response.  That helped me with another problem.  Unfortunately,  I do not think that works for my posted problem.  Let me explain. 

       

      For each unique Ctr_Id in tblCtrMtrDetail, I need as many rows as their are indices associated with the price schedule associated with the Ctr_Id.  For example, for Ctr_Id =1 and Mtr_Id = 1, I have volume 100.  Ctr_Id =1 has an associated Price Schedule Id =1.  Price Schedule Id = 1, has 3 price indices associated with it Index_Id ={1,2,3} with Index_Proportions of {25%,25%,50%} for index 1,2,and 3 respectively.  For the given CtrMtr combination (1,1), I would need 3 rows in my auto-generated table.

       

      for that scenario the three output table rows would need to be:

      Ctr Id   Mtr Id   Sched_Id   Index_Id   Allocated Volume

      1          1           1               1              25

      1          1           1               2              25

      1          1           1               3              50

      • Anonymous's avatar
        Anonymous
        Not applicable

        TonySwad,

        Could you please share sample data of your tables?

        Regards,
        Lydia