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
VTB
Frequent Visitor

Help with making powerBI understand Date relationships

hi all, 

 

I've searched for a while to see if someone solved this, but havent come across it yet. 

 

Issue i am having is with the limitation of one 1 relationship allowed in powerBI between tables, and date fields not being automatically recognized. 

So the scenario I am trying to solve is:

 

if I have 2 tables, 

 

table 1   
Ref DateDrug TrialTypeCell Count
12/31/2018Ayc50
3/31/2019Brt25
6/30/2019Cdx36
table 2   
Ref DateHoldTrial 1Result
12/31/20186A0.26
1/31/20197B0.95
2/28/20193C0.27
3/31/20199A0.40
4/30/20194B0.17
5/31/201912C0.91
6/30/201970A0.11
7/31/201930B0.67
8/31/20193C0.55

 

i am trying to make this work, where i could select Trial & Date from table 1, and it would bring up applicable results from table 2. 

When i make the filter Date & Trial from table 1, say set to A & 12.31, i end up with below

 

 Table in powerBI   
Filter on this:    
from table 1from table 1from table 1from table 2from table 2
Ref DateDrug TrialCell CountTrial 1Result
12/31/2018A50A0.26
12/31/2018A50A0.40
12/31/2018A50A0.11

 

instead of just bring up the first result that matches 12/31, and not bring in the other A results for other dates.

 

because i have manually set up a relationship between the two tables for powerBI to understand that Drug Trial = Trial 1. 

If i set up Ref Date = Ref Date column, I can control that, but then PowerBI doesnt understand that A in Drug Trial is same A as in Trial 1. 

I've configured both columns to be Dates (from sql perspective, and tables coming into powerbi treat them as such), but it wont allow me to make one of them "Date" (that new powerBI model setting button) because the dates are quarterly, not monthly I think. 

 

So I can bypass this by simply setting up two Date filters, but thats confusing to end users as to what they need to select. 

I've tried setting up a middle "Date" table to link relationships to that, but that doesnt work either as powerBI doesnt allow more than one reference it seems to a table/column combo. 

 

Thus... stuck on how to solve this type of issue in powerBI, which comes up quite often when working with multiple tables that share date columns but need other relationships established to filter properly. 😞 

 

 

 

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Yes, you will need to define the relationships between the tables.  In my example I have the 4.

relationships.jpg

You want the many side to be Table1 and Table2 and the one side the be Dates and Trials.

Once you have the relationships set the visual should work.

View solution in original post

4 REPLIES 4
jdbuchanan71
Super User
Super User

Hello @VTB ,

I think you will need a Dates table and a Trails table in order to relate the data the way you want.  You can create the Trials table with this measure.

Trails = 
DISTINCT (
    UNION (
        VALUES(Table1[Drug Trial]),
        VALUES(Table2[Trial 1])
    )
)

drugtrialtables.jpg

This will let you make views relating the values from the tables by date and trial.  Pull in Date from the Dates table and Drug Trial from the Trials table:

drugtrialvisual.jpg

Hey, thanks for answering! 

 

Got as far as creating the Trials and Dates table, union works in the Trials table, but when I go to select columns - dates breaks the powerBI view where it just says "Cant display Visual". 

 

my tables also dont have the arrows showing the relationships - did you have to define some of them in the "Manage Relationships" for end table to work? 

Yes, you will need to define the relationships between the tables.  In my example I have the 4.

relationships.jpg

You want the many side to be Table1 and Table2 and the one side the be Dates and Trials.

Once you have the relationships set the visual should work.

awesome thanks!

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.