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
Anonymous
Not applicable

How to make relation between two tables with two fields

Hi all, I have two Main tables Say "B" and "C" both have random dates data with different data. i.e Many to Many

So I have created a Date Table called "A" which have Unqiue Dates from 2018 to 2022.

 

I am trying to use a Date slicer as shown in below image ,but the Table C not getting filtered w.r.t dates selected from "A"

Screenshot :

skondi_0-1600191724950.png

I am not able to filter C table data as B&C are already in relationship with "MUID" field. how can I make double relational.

One for Date and other for MUID.

 

Screenshot two gives the data structure demo & the outputs which I am expecting for date slicer : 

skondi_0-1600238985274.png

 

 

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hello @skondi ,

The first solution has provided specific steps that you can take to modify relationships. After that, ifd You want to display filtered items in a visual, you may need to create measures to combine the result or count them or others because there may be more than one item on the same day and with the same MUID that cannot be displayed directly in some visuals. Take the following steps for a reference.

All Data =
VAR __selectDate = SELECTEDVALUE('Calendar'[Date])
VAR __selectMUID = SELECTEDVALUE(MUID[MUID])
VAR __allData = CALCULATETABLE(DISTINCT(B[Data]), B[Datekey] = __selectDate, B[MUID] = __selectMUID)
RETURN
CONCATENATEX(__allData,B[Data],",")

All Type =
VAR __selectDate = SELECTEDVALUE('Calendar'[Date])
VAR __selectMUID = SELECTEDVALUE(MUID[MUID])
VAR __allType = CALCULATETABLE(DISTINCT(C[Type]), C[Datekey] = __selectDate, C[MUID] = __selectMUID)
RETURN
CONCATENATEX(__allType,C[Type],",")

v-jingzhang_0-1600402132642.jpeg

Best regards

Community Support Team _ Jing Zhang

If this post helps,please consider Accepting it as the solution to help other members find it.

View solution in original post

3 REPLIES 3
v-jingzhang
Community Support
Community Support

Hello @skondi ,

The first solution has provided specific steps that you can take to modify relationships. After that, ifd You want to display filtered items in a visual, you may need to create measures to combine the result or count them or others because there may be more than one item on the same day and with the same MUID that cannot be displayed directly in some visuals. Take the following steps for a reference.

All Data =
VAR __selectDate = SELECTEDVALUE('Calendar'[Date])
VAR __selectMUID = SELECTEDVALUE(MUID[MUID])
VAR __allData = CALCULATETABLE(DISTINCT(B[Data]), B[Datekey] = __selectDate, B[MUID] = __selectMUID)
RETURN
CONCATENATEX(__allData,B[Data],",")

All Type =
VAR __selectDate = SELECTEDVALUE('Calendar'[Date])
VAR __selectMUID = SELECTEDVALUE(MUID[MUID])
VAR __allType = CALCULATETABLE(DISTINCT(C[Type]), C[Datekey] = __selectDate, C[MUID] = __selectMUID)
RETURN
CONCATENATEX(__allType,C[Type],",")

v-jingzhang_0-1600402132642.jpeg

Best regards

Community Support Team _ Jing Zhang

If this post helps,please consider Accepting it as the solution to help other members find it.

amitchandak
Super User
Super User

@Anonymous , Table A to B or C can not be Many to Many.

 

Create a date table using a calendar.  Join with date column of B and C , should be 1 to M Join.

Create bridge/Diemsion Tables for the common field between B and C

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions

Appreciate your Kudos.

 

PaulDBrown
Community Champion
Community Champion

@Anonymous 

You need to change the model.

1) delete the many-to-many between B and C

2j create a one-to-many from your date table to each B and C tables.

3) create a new dimension table with unique values for the field you were using in the many-to-many between B and C . Create a one-to-many between this new dimension table and B and C tables.

4) carry on from there





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






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.