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
jillw
Frequent Visitor

Average Days Open

I am trying to create a  chart similar to the one below that displays the average amount of days that records are open on any given date.uccavg.PNG

This image is from a table containing different reports and it outputs the correct information. The DAX for the measure used above is as follows:

 

Daily Avg Days Open UCC =
Var _currentDate = SELECTEDVALUE('Date'[Date])
Return (
AVERAGEX(
Filter('UCC', 'UCC'[UCC Date Created] < _currentDate && ('UCC'[UCC Closed Date] >= _currentDate || ISBLANK(UCC[UCC Closed Date]))
),
VAR _closedDate = IF(ISBLANK('UCC'[UCC Closed Date]),_currentDate,'UCC'[UCC Closed Date])
RETURN _closedDate - UCC[UCC Date Created]
)
)
 
The data contained in the table I want to create a similar report for looks like this:
SCAR Record ID#SCAR Date OpenSCAR Closed Date
4743/29/2019 
4733/28/2019 
4723/19/2019 
4713/14/2019 
46412/17/20184/2/2019
46311/20/2018 
46111/12/2018 
45911/7/20183/7/2019
45710/12/20183/7/2019
45610/9/20183/5/2019
45510/5/20184/2/2019
4519/10/2018 
4487/30/201811/28/2018
4467/26/20189/12/2018
4457/26/20189/12/2018

 

The Measure I am using for this table is as follows:

 

Daily Avg Days Open SCAR =
Var _currentDate = SELECTEDVALUE('Date'[Date])
Return (
AVERAGEX(
Filter('SCAR', 'SCAR'[SCAR Date Open] < _currentDate && ('SCAR'[SCAR Closed Date] >= _currentDate || ISBLANK(SCAR[SCAR Closed Date]))
),
VAR _closedDate = IF(ISBLANK(SCAR[SCAR Closed Date]),_currentDate,SCAR[SCAR Closed Date])
RETURN _closedDate - SCAR[SCAR Date Open]
)
)

 

The numbers I am getting are almost twice as big as they should be. I have tried rewriting this code several different ways but I am still coming to the same results. I think I might be missing something else that is causing the data to be skewed. 

3 REPLIES 3
madbaird
Frequent Visitor

I am having same issue with almost exact same table.  Need average open per month by fiscal year.  Average needs to be by close date and not open date. Meaning if ticket was opened in November and closed in January, the time open should be reported for January.  This is my table exported to Excel and DaysOpen is done in Excel not from BI:


TicketNbr CreatedOn ClosedOn DateDiff
TCK-347663 5/3/2021 6/7/2021 35
TCK-351210 6/1/2021 6/7/2021 6
TCK-350980 5/28/2021 6/7/2021 10
TCK-351322 6/1/2021 6/7/2021 6
TCK-351631 6/3/2021 6/7/2021 4
TCK-350881 5/27/2021 6/7/2021 11
TCK-351254 6/1/2021 6/7/2021 6
TCK-351417 6/2/2021 6/7/2021 5
TCK-351633 6/3/2021 6/7/2021 4
TCK-349579 5/18/2021 6/7/2021 20
TCK-351052 5/28/2021 6/7/2021 10
TCK-347662 5/3/2021 6/7/2021 35
TCK-351416 6/2/2021 6/7/2021 5
TCK-351451 6/2/2021 6/7/2021 5
TCK-351154 5/31/2021 6/7/2021 7
TCK-350822 5/27/2021 6/7/2021 11
TCK-351114 5/29/2021 6/7/2021 9
TCK-330545 12/2/2020 187
TCK-338001 2/8/2021 119
TCK-338245 2/9/2021 118
TCK-339071 2/17/2021 110
TCK-339764 2/23/2021 104
TCK-340275 2/26/2021 101
TCK-341736 3/11/2021 88
TCK-342112 3/15/2021 84
TCK-343390 3/25/2021 74


parry2k
Super User
Super User

@jillw based on your example data what you are expected to see "avg days" for each day?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@jillw this is what i'm getting

 

image.png



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

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.