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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
FrankNY007
Frequent Visitor

How joins works in Power BI

Hello,

 

I met some problem to figure out how the join works in PowerBI. let us see I have three tables below:

 

Order Table: (Main table, contain all order information)

 

Order IDLocationSales
1990NJ$10
1991NY$12
1992CT$45
1993DC$23
1994NC$43

 

Phone Table:( Contains reconrd and time when we contact customer, one order may have mutiple records, since we contact customer at different time, and it only contain EDR optinon, which menas in column option, it all EDR)

Order IDOptionCall Time
1990EDR6/27/2018 16:53
1990EDR6/27/2018 14:53
1991EDR6/27/2018 19:53
1992EDR6/27/2018 22:53

 

Scanning Table:(Contain scanning data, one order one record, Early Delivery Flag menas delivery early than expetected time)

Order IDEarly Delivey Flag
1990Y
1991Y
1993Y

 

I import the data into power bi and buil the relationship:

 

1.jpg

 

Now if I only bring Order.Order ID and Scanning.Early Delivey Flag, I got this, so even order ID that didn't has record in scanning will show( for me, it is like a outer join)

 

2.jpg

 

Then if I bring Order.Order ID and Phone.Option in, I only got orders that has records in Phone table(it is becasue of it is 1:M relationshio??)(inner join??

 

3.jpg

My goal is to count how many order in order tbale, than has early flay="Y' but not has record in phone table, for those sample data only 1993 matches, so I should got 1.

 

However I canont do it, use cacalate(distinctconut(order.oder_id),filter(phone,phone.option<>"EDR"), filter(scaning.early_flag="Y"), it return null

 

if i change to cacalate(distinctconut(order.oder_id),filter(phone,phone.option="EDR"), filter(scaning.early_flag="Y"), it give me 2 (1990, 1991 clearly).

 

So what happens here? Intersting thing is: if I delete any duplicate reconrd in my phone call table, and make it 1:1 to my order table, then my fomula works

3 REPLIES 3
Anonymous
Not applicable


@FrankNY007 wrote:

Hello,

 

I met some problem to figure out how the join works in PowerBI. let us see I have three tables below:

 

Order Table: (Main table, contain all order information)

 

Order IDLocationSales
1990NJ$10
1991NY$12
1992CT$45
1993DC$23
1994NC$43

 

Phone Table:( Contains reconrd and time when we contact customer, one order may have mutiple records, since we contact customer at different time, and it only contain EDR optinon, which menas in column option, it all EDR)

Order IDOptionCall Time
1990EDR6/27/2018 16:53
1990EDR6/27/2018 14:53
1991EDR6/27/2018 19:53
1992EDR6/27/2018 22:53

 

Scanning Table:(Contain scanning data, one order one record, Early Delivery Flag menas delivery early than expetected time)

Order IDEarly Delivey Flag
1990Y
1991Y
1993Y

 

I import the data into power bi and buil the relationship:

 

1.jpg

 

Now if I only bring Order.Order ID and Scanning.Early Delivey Flag, I got this, so even order ID that didn't has record in scanning will show( for me, it is like a outer join)

 

2.jpg

 

Then if I bring Order.Order ID and Phone.Option in, I only got orders that has records in Phone table(it is becasue of it is 1:M relationshio??)(inner join??

 

3.jpg

My goal is to count how many order in order tbale, than has early flay="Y' but not has record in phone table, for those sample data only 1993 matches, so I should got 1.

 

However I canont do it, use cacalate(distinctconut(order.oder_id),filter(phone,phone.option<>"EDR"), filter(scaning.early_flag="Y"), it return null

 

if i change to cacalate(distinctconut(order.oder_id),filter(phone,phone.option="EDR"), filter(scaning.early_flag="Y"), it give me 2 (1990, 1991 clearly).

 

So what happens here? Intersting thing is: if I delete any duplicate reconrd in my phone call table, and make it 1:1 to my order table, then my fomula works


Power BI Joins come into picture when we try to Merge 2 queries:

 

https://www.powerbi-pro.com/en/power-bi-seven-types-of-table-joins/

FrankNY007
Frequent Visitor

Any Idea?

Hi @FrankNY007,

 

In your scenario, you can create a measure below: 

 

Measure = var t=FILTER('Order',ISBLANK(LOOKUPVALUE(PhoneCall[Order ID],'PhoneCall'[Order ID],'Order'[Order ID])))
return
COUNTX(FILTER(t,RELATED('Scanning'[Early Delivey Flag])="Y"),[Order ID])

 

q1.PNG

 

Best Regards,
Qiuyun Yu 

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

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.