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
Anonymous
Not applicable

Average no. of days between two days

There are 2 visual as below:

seefadeeb_0-1609176758256.png

I created the below measure to calculate the average number of days taken from start date to end date per employee, where end date is not blank.

 

Avg Days to Close =
CALCULATE(
AVERAGEX(DATA,DATA[End Date]-DATA[Start Date)
,FILTER(
               ALLEXCEPT(DATA,DATA[Employee Name],DATA[Start Date])
                   ,NOT(ISBLANK(DATA[End Date]))
            )
       )
 
Sample Data used to create the above visuals:
seefadeeb_0-1609177577086.png

 

The above measure is working fine in the table visual. But when i select any particular month in the bar graph, the result of average days to close a request is not changing and getting same value for all the month. See the below attached screenshot when i filtered with a selected a particular month.
I have included the start data in the ALLEXCEPT() formula, yet it is not working. What error did I commit? Please help me in resolving this issue.
 

In the below screeshot, i selected Jan, yet the avg days to close column not getting changed @Fowmy 

 
 

Capture.PNG

1 ACCEPTED SOLUTION
mahoneypat
Employee
Employee

Your ALLEXCEPT is removing the filter on the Month column which is why it is not changing.  A simpler way to write your measure might be

 

Avg Days to Close =
AVERAGEX (
    FILTER (
        DATA,
        NOT (
            ISBLANK ( Data[End Date] )
        )
    ),
    DATEDIFF(DATA[Start Date], DATA[End Date], DAY)
)

 

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

5 REPLIES 5
mahoneypat
Employee
Employee

The ALLEXCEPT in your original measure was removing the filter from the Month column, as you did not specify it.  It kept the filter on start date, which is not used in your visual.  For this measure, as the Filter on employee name comes from the visual, the only change to the evaluation context needed is the FILTER to avoid blank end dates.


Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


mahoneypat
Employee
Employee

Your ALLEXCEPT is removing the filter on the Month column which is why it is not changing.  A simpler way to write your measure might be

 

Avg Days to Close =
AVERAGEX (
    FILTER (
        DATA,
        NOT (
            ISBLANK ( Data[End Date] )
        )
    ),
    DATEDIFF(DATA[Start Date], DATA[End Date], DAY)
)

 

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

@mahoneypat Thanks for the solution, this worked. I have a query on this, the ALLEXCEPT() function is filtering on employee name in the table visual, as it is filtering data for the employee name and why is it not filtering with the start month

Greg_Deckler
Super User
Super User

@Anonymous - Where is your Month column coming from? Is it related to your Start Date?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler Yes month column is coming from Start Date

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.

Top Solution Authors