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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
martinsdaniele
Frequent Visitor

Count Dates to get Average

Hi!

 

I need a card to show me the average of itens opened/day/employee. Is there a way for me to count this days?

For exemple, in the data below, I have 4 days (without the repetition) and 11 itens opened by 3 different employees.

 

The average would be:

 

Employee 1:  1,25 items opened by day

Employee 2:  0,75 items opened by day

Employee 3: 0,75 items opened by day

 

But I can't think of a way to count these days in which we have items...

 

EmployeeMaterialDate
1AXT00004/09/2022
2AXT00104/09/2022
3AXT00204/09/2022
1AXT00304/11/2022
2AXT00404/11/2022
1AXT00504/13/2022
1AXT00604/13/2022
1AXT00704/13/2022
3AXT00804/15/2022
2AXT00904/15/2022
3AXT01004/15/2022
1 ACCEPTED SOLUTION
SpartaBI
Community Champion
Community Champion

@martinsdaniele 

Avg Per Employee = 
AVERAGEX(
    VALUES('Table'[Employee]),
    VAR _min_date = CALCULATE(MIN('Table'[Date]))
    VAR _max_date = CALCULATE(MAX('Table'[Date]))
    VAR _days = INT(_max_date - _min_date)
    VAR _items = CALCULATE(COUNTROWS('Table'))
    RETURN
    DIVIDE(_items, _days)
) 


But I'm getting this:

SpartaBI_0-1651251871256.png

This are the days calculated for every employee:

SpartaBI_1-1651251995247.png

between 09/04 and 13/04 there 4 days not inclusive, but 5 inclusive so if 5 is what you want just add 1 to the VAR _days.
Anyway, in either option I didn't ge tthe numbers you wrote. Even if i took distinct count of the days instead of their diff.
If it should be your numbers, can you share the logic how you need to get to them
For example, 
how many days need to be for each employee (only days where he open a ticket or the diff days etc)

View solution in original post

1 REPLY 1
SpartaBI
Community Champion
Community Champion

@martinsdaniele 

Avg Per Employee = 
AVERAGEX(
    VALUES('Table'[Employee]),
    VAR _min_date = CALCULATE(MIN('Table'[Date]))
    VAR _max_date = CALCULATE(MAX('Table'[Date]))
    VAR _days = INT(_max_date - _min_date)
    VAR _items = CALCULATE(COUNTROWS('Table'))
    RETURN
    DIVIDE(_items, _days)
) 


But I'm getting this:

SpartaBI_0-1651251871256.png

This are the days calculated for every employee:

SpartaBI_1-1651251995247.png

between 09/04 and 13/04 there 4 days not inclusive, but 5 inclusive so if 5 is what you want just add 1 to the VAR _days.
Anyway, in either option I didn't ge tthe numbers you wrote. Even if i took distinct count of the days instead of their diff.
If it should be your numbers, can you share the logic how you need to get to them
For example, 
how many days need to be for each employee (only days where he open a ticket or the diff days etc)

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.