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
btalahmbong
Advocate I
Advocate I

Calculate difference using 2 dates in 1 table

Hi,

 

I have 2 dates column in my case table; 'created on' & 'resolved on'. I want to calculate the net difference between cases created and reolved on.

 

So far, I have 2 measures to calculate the sum of cases created and resolved. These are based on each table. Then, I have a measure calculating the difference of these 2 measures.

 

The problem occurs when putting the net difference measure on a visual. If I use the 'created on' date, the cases resolved will be calculated based on the date they were created as opposed to when the were resolved and vice versa.

 

How can I have a date column that will adhere to both date conditions ('created on' & 'resolved on') when put on a visual to show the net difference?

 

Thanks!

 

 

1 ACCEPTED SOLUTION
vanessafvg
Super User
Super User

@btalahmbong you need to use the userelationship function

 

when you create relationships to your calendar table (assuming you have one?), there can be only one primary (active) relationship, that will be the default, the inactive relationship will have a dotted line 

 

can you post a pic of your relationships.

 

therefore for your measure for the inactive relationship, say its the resolved on date

 

calculate(measure, userelationship([table]resolvedondate, calendar[date]))





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
vanessafvg
Super User
Super User

@btalahmbong you need to use the userelationship function

 

when you create relationships to your calendar table (assuming you have one?), there can be only one primary (active) relationship, that will be the default, the inactive relationship will have a dotted line 

 

can you post a pic of your relationships.

 

therefore for your measure for the inactive relationship, say its the resolved on date

 

calculate(measure, userelationship([table]resolvedondate, calendar[date]))





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




@vanessafvg Thanks a lot. 

 

I already had an inactive relationship (Case[modified.Id], User[User Id]) on the 'cases resolved' measure so didn't know it was possible to have more than 1 inactive relationship on a measure. But that worked perfectly. Thanks a lot.

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.