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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Shpongle
Helper III
Helper III

Calculating date opened and date closed in same report

I know, I know! This question has been asked a million times 😁

 

The problem is, I can not figure it out.

 

I have a ServiceData table with the following fields:

TicketNbr, Date_Opened_UTC, Date_Closed_UTC

 

I have a separate Calendar table marked as the date table.

 

I have created an active relationship between Calendar[Date] and ServiceData[Date_Opened_UTC]

I have created a passive relationship between Calendar[Date] and ServiceData[Date_Closed_UTC]

 

All date fields are set to type: Date

 

To get my counts, I created two measures as follows:

Measure TicketsClosed = CALCULATE(count(ServiceData[TicketNbr]),USERELATIONSHIP(ServiceData[Date_Closed_UTC],'Calendar'[Date]))
Measure TicketsOpened = count(ServiceData[TicketNbr])
 
If I create a Table visual, pull in the Calendar[date] field, then set to not use heirarchy it shows me each day in the calendar range, as such:
TableViewWithoutMeasure.png
 If I then add the Measure TicketsClosed and Measure TicketsOpened, I was hoping to see the number of tickets opened and closed each day but instead it removes all the dates and just shows me a count of the TicketNbr as shown:
TableViewWithMeasure.png
 
I suspect that the relationship is not being used/observed. I HAVE successfully gotten this working before with another data table. I'm not sure why this one would be any different!
 
Thanks
1 ACCEPTED SOLUTION

Hi @Shpongle ,

Based on my test, it is indeed related to the data type. The data type of the date in calendar table and fact table should be the same from the beginning.

For example, when your calendar table is date type, your fact table is date/time type but you have changed them to date already, it will show the result just like your latest reply.

tab1.png

If your fact table and calendar table are date types or date/time types initially, it will work fine.

tab2.pngtab3.png

 

My test sample file is attached that you can refer, hopes to help you understand it: Calculating date opened and date closed in same report.pbix 

 

Best Regards,
Yingjie Li

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

7 REPLIES 7
lbendlin
Super User
Super User

 Is the Date field really a column or maybe a measure? In which case you want to say "Don't summarize"

 

Also - is your Date_Opened_UTC a DateTime field or a Date field?  In which case why call it DateOpenedUTC?

The date field is a column, set as date type, no summary:

DateType.png

DateField.png

 

Date_Closed_UTC is a Date field as well:

DateClosed.png

 

I should mention - the source data is date/time but I changed all to date after importing into PowerBI... Could that have something to do with that?

Hi @Shpongle ,

Based on my test, it is indeed related to the data type. The data type of the date in calendar table and fact table should be the same from the beginning.

For example, when your calendar table is date type, your fact table is date/time type but you have changed them to date already, it will show the result just like your latest reply.

tab1.png

If your fact table and calendar table are date types or date/time types initially, it will work fine.

tab2.pngtab3.png

 

My test sample file is attached that you can refer, hopes to help you understand it: Calculating date opened and date closed in same report.pbix 

 

Best Regards,
Yingjie Li

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

Potentially. Rather than changing it I would add another column in Power Query with just the date value.

 

Your measure formula works fine for me.  However you need to enable "Show items with no data" for scenarios where on a particular day no tickets were opened.  If you don't do that then the closed tickets won't show up either.

 

Annotation 2020-06-13.png

OK - now I can see that the ticket counts are not being associated with any date!

 

WithMeasure.png

 

A little bit of progress, but now what do I do?? 🤔

Hi,

Share the link from where i can download your PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

check the table relationships again, make sure the right fields are selected. It works for me.

 

Annotation 2020-06-13a.png

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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