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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
luisbarreto
New Member

USERELATIONSHIP not working as expected with date

Dear helpers, I have thought about this problem for many many months and could not find solution. I hope you can help me.

 

My painel has 2 equal calendar tables to bring some information about 2 columns.

Here are the primary keys in both links to my Requests Table:
1.1) Approval Date

1.2) Deadline Delievery Date

 

My 2 calendar tables (Excel sheet imported in Power BI) have these variables:

2.1) Date (primary key linked in both cases)

2.2) DaysMonth (how many days are in that month)

2.3) DaysNextMonth (how many days are in the next month of that date)

2.4) NextWorkDay (how many days until the next workday

2.5) WorkDay (set 1 from monday to friday and 0 to saturday and sunday)

 

Here's the problem: When I try to use USERELATIONSHIP to stop using 2 calendar tables, the results are wrong.

I use RELATED to bring variables 2.2 and 2.3  to my Requests Table linking 1.1 and 2.1.

I'm trying to substitute RELATED in the second calendar table to bring variables 2.4 and 2.5 to my Requests Table linking 1.2 and 2.1 to use USERELATIONSHIP in the first calendar table to bring variables 2.4 and 2.5 to my Requests Table linking 1.2 and 2.1.

When I try to substitute this, I see this difference:

Using RELATED in calendar 2 I have 47 workdays in my report (Right answer, but with 2 calendar tables)

Using USERELATIONSHIP in calendar 1 I have 67 workdays in the same report (Wrong answer, but with 1 calendar tables)

Using USERELATIONSHIP (exactly the same command!) in calendar 2 I have 47 workdays in the same report (Right answer, but with 2 calendar tables)

 

I tried to change calendar table 2 for 1 in dax commands, but they are exactly the same calendar and I had no progress. Also, I tried to put a side-by-side filter on the second link to try to fix this and I also had another wrong answer (5 workdays).

 

Thus, I see I can just use USERELATIONSHIP in a calendar table if this relationship is the main relationship.

Can someone help me to use just 1 calendar table?

2 REPLIES 2
amitchandak
Super User
Super User

@luisbarreto , if you have two calendar tables. Then both will have active relationship. what is role of userelationship

 

Single table joining to two dates needs userelationship 

 

examples

https://radacad.com/userelationship-or-role-playing-dimension-dealing-with-inactive-relationships-in...

https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks for your reply, @amitchandak .

 

However, my relationships to both calendar tables are already active.

My trouble is when I do two relationships in just one calendar table by using USERELATIONSHIP when I try to link my secondary key (we can't active 2 relationships in the same table with the same column at the same time) to my calendar to get the information I need.

 

In thesis, it should resolve, it should bring me the right answer (47 workdays) using USERELATIONSHIP with my secondary key. But it doesn't work.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.