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
Robin9700
Helper I
Helper I

Relation based on two columns

Hello!

 

I need help creating a relationship between two tables. I have two tables regarding ledger entries; one table with the details for each entry, the other table with the details for each entry-batch.

For example, in table 1 there are 3 columns: description, entry number and amount.

[Purchase of goods]   [entry 1]  [€100] 

[Purchase of service]  [entry 2]  [€350]

[Purchase of goods]   [entry 3]  [€20]

 

And in table 2 there are 4 columns: date, booking type, first entry number, and last entry number (of the batch)

[Date]  [Purchases]  [entry 1]  [entry 3]

 

Now, I want to show all purchases that are done on [Date]. So, I need table 2 to show the individual entries and their descriptions, instead of just the first and/or last one. Basically, I need a relationship based on 'first entry < entry# > last entry'. 

 

Does anyone know how to do this, with a DAX or PowerQuery for example?

 

Thanks!

1 ACCEPTED SOLUTION

Hi @Robin9700 ,

I created another new sample pbix file(see attachment) base on the data of your provided tables, please check whether that is what you want.

yingyinr_0-1622791895055.png

Best Regards

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

View solution in original post

7 REPLIES 7
Robin9700
Helper I
Helper I

@v-yiruan-msft Thanks again for your reply!

 

Table 2 is indeed exactly what I need.

Table 1 is like the one I already have.

 

I see I am not allowed to upload files and/or images, so I will try to explain this again.

Table 1 looks like this:

DescriptionEntry numberAmount
Purchase of goods1€100
Purchase of goods2€350
Purchase of goods3€20
Sales4€125
Sales5€250
Purchase of goods6€50
Purchase of goods7€100
Purchase of goods8€10

 

And the other table I have (which is not in your file) looks like this:

DateDescriptionFirst entry numberLast entry number
May 12, 2021Purchase of goods13
May 17, 2021Sales45
May 20, 2021Purchase of goods68

 

And what I need right now, is a way to connect or merge those 2, to eventually create visuals with the following data (like table 2 in your file):

DateDescriptionEntry numberAmount
May 12, 2021Purchase of goods2€350
May 17, 2021Sales4€125
May 20, 2021Purchase of goods6€50
May 12, 2021Purchase of goods1€20

 

So basically, what I need, is table 1 & 2 to form table 3 together. Can you help me with that?

Hi @Robin9700 ,

I created another new sample pbix file(see attachment) base on the data of your provided tables, please check whether that is what you want.

yingyinr_0-1622791895055.png

Best Regards

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

Thank you so much! I was able to recreate the 'Entries' column and expand it, and now my data does what it should do 🙂 

 

Have a good day!

v-yiruan-msft
Community Support
Community Support

Hi @Robin9700 ,

Could you please provide some sample data(exclude sensitive data) in table 1 and table2 and your expected result with examples just as show in below tables? Thank you.

1. Sample data

table 1

description entry number amount
Purchase of goods entry 1 100
Purchase of service entry 2 350
Purchase of goods  entry 3 20

table 2

date booking type entry 1 entry 3
2021/5/12 purchase 20 30

2. Expected result?

date booking type entry number description value
2021/5/12 purchase entry 1 Purchase of goods 20
2021/5/12 purchase entry 3   30

Best Regards

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

Hi, thanks for your reply!

 

The result I want to show from the two tables, is:

Entry# - date - description - amount(€)

 

Table 1 shows the description and the amount. Table 2 contains the date and entrynumbers, however the entrynumbers are shown as "entry1 up to entry4", with both the first and last entry# of the 'batch' in different columns.

 

To see the date for 1 specific entry number, for example entry2, I need to use something like a VLookup would do in Excel, I think. However, I am not able to establish a relationship between the 2 tables at this moment. Do you have any suggestions?

Hi @Robin9700 ,

Sorry for delay. I created a sample pbix file(see attachment), please check whether that is what you want.

yingyinr_0-1622626372781.png

If the above one is not what you want, please provide some sample data in your tables and your expected result with specific examples and involved logic. Thank you.

Best Regards

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

If these columns are integers->  [entry 1]  [entry 3] , then a fairly elegant Power Query solution is available.

How do you link the batch between the 2 tables though?

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.