Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
TonySwad
Frequent Visitor

Dynamically Generate a Table from Information Distributed Across Data Structure

DataStructure.GIF

 

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 4
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?

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

@TonySwad,

Could you please share sample data of your tables?

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

The following are samples of the data in the tables relevant to my posted problem.

The following table relates to a contract entity and is used to relate a schedule to each contract.

Ctr_Id          Co_Id         Cust_Id      Sched_Id

1111
2222
3333
4144
5251
6312
7123
8234
9341
10152
11213
12324
13131
14242
15353
16114
17221
18332
19143
20254
21311

 

The following table is the detail for the rate schedules.  Each rate schedule is the weighted average of one or more indices.  The table contains a row for each index used in a given rate schedule and the weighting applied to the index in that given rate schedule.

 Sched_Id  Index_Id  Index_Proportion

110.25
120.25
130.25
140.25
210.5
220.5
310.333333333
320.333333333
330.333333333
411

 

This table contains metered volumes assigned to a contract in a given month.

Ctr_Id      Mtr_Id    Volume          Prod Date

19           5,81012/1/2017
119         3,08112/1/2017
120           2,38812/1/2017
22         2,98512/1/2017
234               48812/1/2017
239         8,47012/1/2017
311           4,94612/1/2017
425       (7,056)12/1/2017
440           5,68712/1/2017
54         8,32512/1/2017
616           8,88312/1/2017
618       (9,178)12/1/2017
624             (245)12/1/2017
631       (6,818)12/1/2017
637         (2,811)12/1/2017
717       (2,447)12/1/2017
730           2,28812/1/2017
827         4,51612/1/2017
914           7,99512/1/2017
921         4,01112/1/2017
929           6,18412/1/2017
1026         7,25512/1/2017
117         (7,500)12/1/2017
1133       (4,271)12/1/2017
1210           4,02912/1/2017
135       (1,131)12/1/2017
1328             (877)12/1/2017
141           (258)12/1/2017
1436             (844)12/1/2017
1438       (6,577)12/1/2017
1512         (4,918)12/1/2017
163         3,98212/1/2017
1715           5,15312/1/2017
1735       (9,369)12/1/2017
186         (1,346)12/1/2017
198           (917)12/1/2017
1913           9,83812/1/2017
2022       (4,111)12/1/2017
2032         (9,260)12/1/2017
2123       (1,758)12/1/2017

The problem is to allocate the metered volumes per contract-meter-month record to the individual indices to which the metered volume is exposed.  I was hopeful of creating a table with the following headings:

 

Ctr_Id  Mtr_Id  Prod_Mo Sched_Id  Index_Id   Volume

 

such that when I added the volume for a given Ctr_Id Mtr_Id Prod_Mo across Index_Id's, the total would equal the volume for the Ctr_Id Mtr_Id Prod_Mo record in the 3rd table above.

 

By generating such a table, I can write one set of measures on that table that allows me to report at the level of detail I require.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.