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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
TMQ
Regular Visitor

Creating relationships between multiple tables

Hi, very much a new user.... I have 5 data tables, all with similar column headings and granularity, just with different price data in each.  e.g.:

Table 1

Date  Hour  PriceA

 

Table 2

Date  Hour  PriceB

 

Table 3

Date  Hour  PriceC

 

I want to build a report so that I can compare the PriceA/B/C in any date or hour.  When I try create the relationships between either the date or hour fields I get either the error "This could be because there is missing intermediate data to connect the two columns" or "you can't create a relationsip between these two columns because one of the columns must have unique values".

 

I looked at other similar posts on here, but can't work out the solution.

 

Any ideas....?  Thanks.

5 REPLIES 5
SourceToShare
Frequent Visitor

TMQ,

 

Have you considered unioning the 5 tables into one?  You will need to add another column to identify item (A, B, C,...).  So your resultant table would have the columns

 

Date / Hour / Price / Item

 

You can do this in the "Edit Queries" window by using "Append Queries".  There's even an option to do "Three or more tables" which would be helpful in this case.

 

Does that help?


~ Derek

I'll give that a try and let you know..... thanks!

TMQ
Regular Visitor

No luck on the appending queries.... maybe the below picture will help explain.  The five tables have similar (not exactly the same) data in the first three fields, and then I want to build reports analysing the remaining fields.  When I tried to append the queries it brought it all together, but then I had an extra column with "null" in it.

 

PowerBI screen1.jpg

 

TMQ
Regular Visitor

i'm making some more progress with the query.... however, the table smpEP2 doesn't have a field called "RUN_TYPE".... so I tried to add one, by making a new column, and putting the label "EP2" in every row.  When I append the query it is bringing in the EP1 data twice (once with blank RUN_TYPE labels), but not the EP2 values.

 

Similarly, I was trying to add a 6th table.  I renamed some of the columns, and created a couple, so that they had similar column names and values to the others.  When I append the query with this new table it isn't bringing it in at all..... when you append queries will it bring in all data with the same column headings into the table?

 

I've tried a few queries tutorials online, but not getting very far!

kcantor
Community Champion
Community Champion

What you need is a lookup or bridge table. Add a date table with all dates (no skipped dates) and relate all of the other tables through one particular date such as your trade date. then populate your visuals using the date from the date table in the 'rows' and pull the values from the other tables. You can create lookup tables for many different granularities such as product, sales rep, store, and any other field that is consistent across the data.

Check out this link:

http://www.powerpivotpro.com/2013/01/calendar-tables-not-just-for-formulas-use-them-on-your-pivots-t...





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.