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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

USERELATIONSHIP with multiple dates

I have a list of services with IDs that have an open date and a closed date on the same record line in a table. They look like so:

IDOpened DateClosed Date
110/22/201911/4/2019
211/4/201911/4/2019
311/4/201911/6/2019
411/5/201911/7/2019
511/7/201911/12/2019
611/8/201912/17/2019
711/13/2019 
811/13/2019 
911/19/20191/3/2020

 

I've created a Calendar table with an Active Relationship from the Date column to Opened Date column in my dataset, as the majority of sorting I'll do with the expanded dataset uses that column. 

If I wanted to take a look at all the services that were opened (created) in the month of November, I'd set my slicer from the Calendar table with a minimum date of 11/1/2019 and a maximum date of 11/30/2019 then create a Measure:

 

Count of Opened Cases = COUNTROWS(ID)

 

This gives me a total of 8, which is great! When I took specifically at the data to validate, I like what I see:

 

IDOpened DateClosed Date
211/4/201911/4/2019
311/4/201911/6/2019
411/5/201911/7/2019
511/7/201911/12/2019
611/8/201912/17/2019
711/13/2019 
811/13/2019 
911/19/20191/3/2020

 

Now I want to see the services that were CLOSED in the month of November. Similar counting methodology, but within a given date range with the Closed Date column. Since the Calendar table already has an active relationship with the Opened Date column, I create an inactive relationship to the Closed Date column with the Date column from the Calendar table, and then use the USERELATIONSHIP function within a CALCULATE function to do a similar count:

 

Count of Closed Cases = CALCULATE(COUNTROWS(ID), USERELATIONSHIP(Services[Closed Date],'Calendar'[Date]))

 

The expected total I should get is 5, as these should be the services that come up:

 

IDOpened DateClosed Date
110/22/201911/4/2019
211/4/201911/4/2019
311/4/201911/6/2019
411/5/201911/7/2019
511/7/201911/12/2019

 

However, when I display my count, it's 8, the same as my Count of Opened Cases measure, and the list that remains is the same one as the Opened Date cases.

 

My guess is the date slicer always defaults to the Opened Date column regardless of the measures I've made? Can anyone provide any guidance on how to move forward?

1 ACCEPTED SOLUTION
mwegener
Most Valuable Professional
Most Valuable Professional

Hi @Anonymous,

 

you need to count the Facttable "Services" and not on a Dimensiontable "ID".

 

You may download my PBIX file from here.
Hope this helps.

 

Regards,

Marcus

Dortmund - Germany
If I answered your question, please mark my post as solution, this will also help others.
Please give Kudos for support.

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

Ensure that there is an inactive relationship between the Closed Date column of your Data Table to the Date column of your Calendar Table.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
mwegener
Most Valuable Professional
Most Valuable Professional

Hi @Anonymous,

 

you need to count the Facttable "Services" and not on a Dimensiontable "ID".

 

You may download my PBIX file from here.
Hope this helps.

 

Regards,

Marcus

Dortmund - Germany
If I answered your question, please mark my post as solution, this will also help others.
Please give Kudos for support.

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


amitchandak
Super User
Super User

Refer, if this can help

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

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
https://community.powerbi.com/t5/Community-Blog/Winner-Topper-on-Map-How-to-Color-States-on-a-Map-wi...
https://community.powerbi.com/t5/Community-Blog/Power-BI-Working-with-Non-Standard-Time-Periods/ba-p...
https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.