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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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...

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.